Skip to content

Commit

Permalink
fix: Enhance error handling in the UI (#3158)
Browse files Browse the repository at this point in the history
* Enhance error handling by including the message content from the response

Signed-off-by: at670475 <andrea.tabone@broadcom.com>

* Fix tests

Signed-off-by: at670475 <andrea.tabone@broadcom.com>

---------

Signed-off-by: at670475 <andrea.tabone@broadcom.com>
  • Loading branch information
taban03 authored Oct 23, 2023
1 parent a071593 commit ee39a4b
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 9 deletions.
4 changes: 2 additions & 2 deletions api-catalog-ui/frontend/src/components/Error/ErrorDialog.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ export default class ErrorDialog extends Component {
}
// eslint-disable-next-line global-require
const errorMessages = require('../../error-messages.json');
if (error && error.messageNumber && error.messageType) {
messageText = 'Unexpected error, please try again later';
if (error?.messageNumber && error?.messageType && error?.messageContent) {
messageText = `(${error.messageNumber} ${error.messageContent})`;
const filter = errorMessages.messages.filter(
(x) => x.messageKey != null && x.messageKey === error.messageNumber
);
Expand Down
9 changes: 2 additions & 7 deletions api-catalog-ui/frontend/src/components/Login/Login.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,8 @@ function Login(props) {
let invalidCredentials;
// eslint-disable-next-line global-require
const errorMessages = require('../../error-messages.json');
if (
error.messageNumber !== undefined &&
error.messageNumber !== null &&
error.messageType !== undefined &&
error.messageType !== null
) {
messageText = `Unexpected error, please try again later (${error.messageNumber})`;
if (error?.messageNumber && error?.messageType && error?.messageContent) {
messageText = `(${error.messageNumber}) ${error.messageContent}`;
const filter = errorMessages.messages.filter(
(x) => x.messageKey != null && x.messageKey === error.messageNumber
);
Expand Down
4 changes: 4 additions & 0 deletions api-catalog-ui/frontend/src/components/Login/Login.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ describe('>>> Login page component tests', () => {
error: {
messageNumber: 'ZWEAT412E',
messageType: 'ERROR',
messageContent: 'Some error',
},
expired: true,
}}
Expand All @@ -39,6 +40,7 @@ describe('>>> Login page component tests', () => {
error: {
messageNumber: 'ZWEAT604E',
messageType: 'ERROR',
messageContent: 'Some error',
},
expired: true,
}}
Expand All @@ -55,6 +57,7 @@ describe('>>> Login page component tests', () => {
error: {
messageNumber: 'ZWEAT414E',
messageType: 'ERROR',
messageContent: 'Some error',
},
}}
/>
Expand All @@ -72,6 +75,7 @@ describe('>>> Login page component tests', () => {
error: {
messageNumber: 'ZWEAT414E',
messageType: 'ERROR',
messageContent: 'Some error',
},
}}
/>
Expand Down

0 comments on commit ee39a4b

Please sign in to comment.