From f10383932f8548e0a44c42e43fd8654186c652da Mon Sep 17 00:00:00 2001 From: shadowusr Date: Thu, 30 Nov 2023 00:20:42 +0300 Subject: [PATCH] fix: handle edge case when error is null --- lib/static/components/state/state-error.jsx | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/static/components/state/state-error.jsx b/lib/static/components/state/state-error.jsx index 12ea61e19..3e0223749 100644 --- a/lib/static/components/state/state-error.jsx +++ b/lib/static/components/state/state-error.jsx @@ -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() { @@ -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; @@ -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 (