Skip to content

Commit

Permalink
fix: handle edge case when error is null
Browse files Browse the repository at this point in the history
  • Loading branch information
shadowusr committed May 20, 2024
1 parent 276cb33 commit f103839
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions lib/static/components/state/state-error.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class StateError extends Component {
_getErrorPattern() {
const {errorPatterns, error} = this.props;

return errorPatterns.find(({regexp}) => error.message?.match(regexp));
return errorPatterns.find(({regexp}) => error?.message?.match(regexp));
}

_drawImage() {
Expand All @@ -61,6 +61,10 @@ class StateError extends Component {
}

_errorToElements(error) {
if (isEmpty(error)) {
return 'Unknown error';
}

return map(error, (value, key) => {
if (!value) {
return null;
Expand Down Expand Up @@ -113,7 +117,7 @@ class StateError extends Component {

const extendedError = isEmpty(errorPattern)
? error
: {...error, message: `${errorPattern.name}\n${error.message}`, hint: () => parseHtmlString(errorPattern.hint)};
: {...error, message: `${errorPattern.name}\n${error?.message}`, hint: () => parseHtmlString(errorPattern.hint)};

return (
<div className="image-box__image image-box__image_single">
Expand Down

0 comments on commit f103839

Please sign in to comment.