Skip to content

Commit

Permalink
pkp/pkp-lib#10337 Show error dialog/notification when form or useFetc…
Browse files Browse the repository at this point in the history
…h receives errors from API
  • Loading branch information
blesildaramirez committed Feb 13, 2025
1 parent c8d9700 commit a448960
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/components/Form/Form.vue
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,7 @@ export default {
*/
error: function (r) {
// Field validation errors
if (r.status && r.status === 400) {
if (r.status && [400, 422].includes(r.status)) {
pkp.eventBus.$emit(
'notify',
this.t('form.errors', {
Expand Down
2 changes: 1 addition & 1 deletion src/composables/useFetch.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ export function useFetch(url, options = {}) {
return; // aborted by subsequent request
}

if (expectValidationError && e.status >= 400 && e.status < 500) {
if (expectValidationError && [400, 422].includes(e.status)) {
validationError.value = e.data;
data.value = null;
return;
Expand Down

0 comments on commit a448960

Please sign in to comment.