Skip to content

Commit

Permalink
UIQM-582: Show correct message if record not found.
Browse files Browse the repository at this point in the history
  • Loading branch information
Dmytro-Melnyshyn committed Nov 6, 2023
1 parent cda817d commit 14f5aaa
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 3 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion src/QuickMarcEditor/QuickMarcEditWrapper.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
3 changes: 2 additions & 1 deletion src/QuickMarcEditor/QuickMarcEditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion src/QuickMarcEditor/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 14f5aaa

Please sign in to comment.