Skip to content

Commit a316535

Browse files
committed
fix: prevent showing 'null' status in ErrorBanner
1 parent 3491d22 commit a316535

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/misc/ErrorBanner/ErrorBanner.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,12 @@ export const ErrorBanner = (props) => {
1111
navigator.clipboard.writeText(message).then(() => setCopyButtonText(labels.toggledButtonText));
1212
};
1313
const errorMessageMaxLength = 200;
14+
const errorStatusText = error.status ? error.status + ' ' : '';
1415
return (
1516
<Slide direction="down" in={error != null} unmountOnExit>
1617
<Paper square elevation={0} className={classes.errorContainer} data-cy="error-banner">
1718
<div>
18-
<Typography className={classes.errorTitle}>{error.status + ' ' + error.title}</Typography>
19+
<Typography className={classes.errorTitle}>{errorStatusText + error.title}</Typography>
1920
<Typography className={classes.errorText}>
2021
{error.detail.length < errorMessageMaxLength ? error.detail : labels.tooLongErrorMessage}
2122
</Typography>
@@ -52,7 +53,12 @@ export const ErrorBanner = (props) => {
5253
};
5354

5455
ErrorBanner.propTypes = {
55-
error: PropTypes.object.isRequired,
56+
error: PropTypes.shape({
57+
comment: PropTypes.string,
58+
detail: PropTypes.string,
59+
status: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
60+
title: PropTypes.string.isRequired,
61+
}).isRequired,
5662
clearErrors: PropTypes.func,
5763
labels: PropTypes.shape({
5864
tooLongErrorMessage: PropTypes.string,

0 commit comments

Comments
 (0)