diff --git a/src/dispatch/signal/views.py b/src/dispatch/signal/views.py index e8dab18aabe7..ffb9bf25d266 100644 --- a/src/dispatch/signal/views.py +++ b/src/dispatch/signal/views.py @@ -157,14 +157,9 @@ def create_engagement( db_session=db_session, creator=current_user, signal_engagement_in=signal_engagement_in ) except IntegrityError: - raise ValidationError( - [ - ErrorWrapper( - ExistsError(msg="A signal engagement with this name already exists."), - loc="name", - ) - ], - model=SignalEngagementRead, + raise HTTPException( + status_code=status.HTTP_404_NOT_FOUND, + detail=[{"msg": "A signal engagement with this name already exists."}], ) from None @@ -195,14 +190,9 @@ def update_engagement( signal_engagement_in=signal_engagement_in, ) except IntegrityError: - raise ValidationError( - [ - ErrorWrapper( - ExistsError(msg="A signal engagement with this name already exists."), - loc="name", - ) - ], - model=SignalEngagementUpdate, + raise HTTPException( + status_code=status.HTTP_400_BAD_REQUEST, + detail=[{"msg": "A signal engagement with this name already exists."}], ) from None return signal_engagement @@ -220,13 +210,9 @@ def create_filter( db_session=db_session, creator=current_user, signal_filter_in=signal_filter_in ) except IntegrityError: - raise ValidationError( - [ - ErrorWrapper( - ExistsError(msg="A signal filter with this name already exists."), loc="name" - ) - ], - model=SignalFilterRead, + raise HTTPException( + status_code=status.HTTP_400_BAD_REQUEST, + detail=[{"msg": "A signal filter with this name already exists."}], ) from None @@ -253,13 +239,9 @@ def update_filter( db_session=db_session, signal_filter=signal_filter, signal_filter_in=signal_filter_in ) except IntegrityError: - raise ValidationError( - [ - ErrorWrapper( - ExistsError(msg="A signal filter with this name already exists."), loc="name" - ) - ], - model=SignalFilterUpdate, + raise HTTPException( + status_code=status.HTTP_404_NOT_FOUND, + detail=[{"msg": "A signal filter with this name already exists."}], ) from None return signal_filter diff --git a/src/dispatch/static/dispatch/src/signal/engagement/store.js b/src/dispatch/static/dispatch/src/signal/engagement/store.js index 86850cd144a3..8b26b63fceb5 100644 --- a/src/dispatch/static/dispatch/src/signal/engagement/store.js +++ b/src/dispatch/static/dispatch/src/signal/engagement/store.js @@ -41,8 +41,14 @@ const actions = { commit("RESET_SELECTED") return resp.data }) - .catch((error) => { - console.log(error) + .catch((err) => { + let errorText = err.response.data.detail.map(({ msg }) => msg).join(" ") + commit( + "notification_backend/addBeNotification", + { text: `Error trying to save: ${errorText}`, type: "exception" }, + { root: true } + ) + commit("RESET_SELECTED") commit("SET_SELECTED_LOADING", false) }) } else { @@ -55,7 +61,14 @@ const actions = { ) commit("SET_SELECTED_LOADING", false) }) - .catch(() => { + .catch((err) => { + let errorText = err.response.data.detail.map(({ msg }) => msg).join(" ") + commit( + "notification_backend/addBeNotification", + { text: `Error trying to save: ${errorText}`, type: "exception" }, + { root: true } + ) + commit("RESET_SELECTED") commit("SET_SELECTED_LOADING", false) }) } diff --git a/src/dispatch/static/dispatch/src/signal/filter/store.js b/src/dispatch/static/dispatch/src/signal/filter/store.js index f6f0bc3cb5cf..bc18ea9f9c67 100644 --- a/src/dispatch/static/dispatch/src/signal/filter/store.js +++ b/src/dispatch/static/dispatch/src/signal/filter/store.js @@ -65,7 +65,14 @@ const actions = { commit("SET_DIALOG_CREATE_EDIT", false) return resp.data }) - .catch(() => { + .catch((err) => { + let errorText = err.response.data.detail.map(({ msg }) => msg).join(" ") + commit( + "notification_backend/addBeNotification", + { text: `Error trying to save: ${errorText}`, type: "exception" }, + { root: true } + ) + commit("RESET_SELECTED") commit("SET_SELECTED_LOADING", false) }) } else { @@ -78,7 +85,14 @@ const actions = { ) commit("SET_SELECTED_LOADING", false) }) - .catch(() => { + .catch((err) => { + let errorText = err.response.data.detail.map(({ msg }) => msg).join(" ") + commit( + "notification_backend/addBeNotification", + { text: `Error trying to save: ${errorText}`, type: "exception" }, + { root: true } + ) + commit("RESET_SELECTED") commit("SET_SELECTED_LOADING", false) }) }