Skip to content

Commit

Permalink
pkp/pkp-lib#10337 Use error as fallback if errorMessage does not exis…
Browse files Browse the repository at this point in the history
…t from error response
  • Loading branch information
blesildaramirez committed Feb 20, 2025
1 parent f25426e commit 31a36d4
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
7 changes: 4 additions & 3 deletions src/components/Form/Form.vue
Original file line number Diff line number Diff line change
Expand Up @@ -460,10 +460,11 @@ export default {
} else if (
r.status &&
[403, 404].includes(r.status) &&
r.responseJSON &&
r.responseJSON.errorMessage
(r.responseJSON?.errorMessage || r.responseJSON?.error)
) {
pkp.eventBus.$emit('notify', r.responseJSON.errorMessage, 'warning');
const errorMessage =
r.responseJSON.errorMessage || r.responseJSON.error;
pkp.eventBus.$emit('notify', errorMessage, 'warning');
} else {
pkp.eventBus.$emit('notify', this.t('common.unknownError', 'warning'));
}
Expand Down
4 changes: 2 additions & 2 deletions src/mixins/ajaxError.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ export default {
}

let msg;
if ('responseJSON' in r && 'errorMessage' in r.responseJSON) {
msg = r.responseJSON.errorMessage;
if (r?.responseJSON?.errorMessage || r?.responseJSON?.error) {
msg = r.responseJSON.errorMessage || r.responseJSON.error;
} else {
msg = this.t('common.unknownError');
}
Expand Down
5 changes: 4 additions & 1 deletion src/stores/modalStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,10 @@ export const useModalStore = defineStore('modal', () => {

/** Default network error */
function openDialogNetworkError(fetchError) {
const msg = fetchError?.data?.errorMessage || t('common.unknownError');
const msg =
fetchError?.data?.errorMessage ||
fetchError?.data?.error ||
t('common.unknownError');

openDialog({
name: 'ajaxError',
Expand Down

0 comments on commit 31a36d4

Please sign in to comment.