Skip to content

Commit

Permalink
Merge pull request #189 from kbss-cvut/186-updated-error-msg
Browse files Browse the repository at this point in the history
186 updated error msg
  • Loading branch information
blcham authored Jul 22, 2024
2 parents 43c02fe + 93ec96d commit 9c52b4c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
8 changes: 3 additions & 5 deletions src/actions/RecordActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,11 +106,9 @@ export function createRecord(record) {
})
.catch((error) => {
dispatch(saveRecordError(error.response.data, record, ACTION_FLAG.CREATE_ENTITY));
dispatch(
publishMessage(
errorMessage("record.save-error", { error: getState().intl.messages[error.response.data.messageId] }),
),
);
const errorMessageText =
getState().intl.messages[error.response.data.messageId] || error.response.data || "An error occurred";
dispatch(publishMessage(errorMessage("record.save-error", { error: errorMessageText })));
});
};
}
Expand Down
2 changes: 1 addition & 1 deletion tests/__tests__/actions/RecordActions.spec.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ describe("Record asynchronous actions", function () {
{ type: ActionConstants.PUBLISH_MESSAGE, message: successMessage("record.save-success") },
{ type: ActionConstants.LOAD_RECORDS_SUCCESS, records },
];

mockApi.onGet(`${API_URL}/rest/users/current`).reply(200, { institution: "Test Institution" });
mockApi.onPost(`${API_URL}/rest/records`).reply(200, null, { location });
mockApi.onGet(`${API_URL}/rest/records`).reply(200, records, {});

Expand Down

0 comments on commit 9c52b4c

Please sign in to comment.