diff --git a/CHANGELOG.md b/CHANGELOG.md index 775a8c45..3a41fd8b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,10 @@ * [UIQM-543](https://issues.folio.org/browse/UIQM-543) Remove eslint deps that are already listed in eslint-config-stripes. * [UIQM-573](https://issues.folio.org/browse/UIQM-573) Edit MARC authority | Allow user to Add/Edit 010 $a when linking is based on 001. +## [7.0.4](IN PROGRESS) + +* [UIQM-582](https://issues.folio.org/browse/UIQM-582) Show correct message if record not found. + ## [7.0.3](https://github.com/folio-org/ui-quick-marc/tree/v7.0.3) (2023-11-03) * [UIQM-571](https://issues.folio.org/browse/UIQM-571) Added `marc-records-editor.item.put` to Derive and Create Bib permissions to fix issue with broken links after deriving or creating a record. diff --git a/src/QuickMarcEditor/QuickMarcEditWrapper.test.js b/src/QuickMarcEditor/QuickMarcEditWrapper.test.js index 7d295b3b..45936e67 100644 --- a/src/QuickMarcEditor/QuickMarcEditWrapper.test.js +++ b/src/QuickMarcEditor/QuickMarcEditWrapper.test.js @@ -515,7 +515,7 @@ describe('Given QuickMarcEditWrapper', () => { describe('when record not found (already deleted)', () => { it('should reveal an error message', async () => { - mutator.quickMarcEditInstance.GET = jest.fn(() => Promise.reject(new Error('Not found'))); + mutator.quickMarcEditInstance.GET = jest.fn().mockRejectedValue({ httpStatus: 404 }); const { getByText } = renderQuickMarcEditWrapper({ instance, diff --git a/src/QuickMarcEditor/QuickMarcEditor.js b/src/QuickMarcEditor/QuickMarcEditor.js index e233acc6..55ab771e 100644 --- a/src/QuickMarcEditor/QuickMarcEditor.js +++ b/src/QuickMarcEditor/QuickMarcEditor.js @@ -407,7 +407,7 @@ const QuickMarcEditor = ({ return; } else if (httpError.code === 'ILLEGAL_FIXED_LENGTH_CONTROL_FIELD') { messageId = 'ui-quick-marc.record.save.error.illegalFixedLength'; - } else if (httpError.message === 'Not found') { + } else if (httpError.httpStatus === 404) { messageId = 'ui-quick-marc.record.save.error.notFound'; } else { messageId = 'ui-quick-marc.record.save.error.generic'; @@ -560,6 +560,7 @@ QuickMarcEditor.propTypes = { code: PropTypes.string, message: PropTypes.string, errorType: PropTypes.string, + httpStatus: PropTypes.number, }), confirmRemoveAuthorityLinking: PropTypes.bool, validate: PropTypes.func.isRequired, diff --git a/src/QuickMarcEditor/utils.js b/src/QuickMarcEditor/utils.js index 027ea901..a543915d 100644 --- a/src/QuickMarcEditor/utils.js +++ b/src/QuickMarcEditor/utils.js @@ -119,7 +119,7 @@ export const parseHttpError = async (httpError) => { if (contentType === 'text/plain') { jsonError.message = await httpError.text(); } else { - jsonError = await httpError.json(); + jsonError = await httpError.json?.() || httpError; } jsonError.errorType = ERROR_TYPES.OTHER;