From d7563cd775e2e07bf9d479fece757433533e0ecf Mon Sep 17 00:00:00 2001 From: Daniel Karbach Date: Wed, 15 Feb 2023 11:36:47 +0100 Subject: [PATCH] improved error reporting --- resources/js/components/common/ErrorBoundary.js | 4 +++- resources/js/components/common/ErrorMessage.js | 6 ++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/resources/js/components/common/ErrorBoundary.js b/resources/js/components/common/ErrorBoundary.js index 4fbc562..83fdb3e 100644 --- a/resources/js/components/common/ErrorBoundary.js +++ b/resources/js/components/common/ErrorBoundary.js @@ -1,6 +1,8 @@ import PropTypes from 'prop-types'; import React from 'react'; +import ErrorMessage from './ErrorMessage'; + class ErrorBoundary extends React.Component { constructor(props) { super(props); @@ -21,7 +23,7 @@ class ErrorBoundary extends React.Component { const { children } = this.props; const { error } = this.state; if (error) { - return

error

; + return ; } return children; } diff --git a/resources/js/components/common/ErrorMessage.js b/resources/js/components/common/ErrorMessage.js index 8829de7..2430bc2 100644 --- a/resources/js/components/common/ErrorMessage.js +++ b/resources/js/components/common/ErrorMessage.js @@ -12,6 +12,12 @@ const ErrorMessage = ({ error }) => {

{i18n.t(`error.${error.response.status}.description`)}

; } + if (error.message) { + return + Error +

{error.message}

+
; + } return
Error
; }; -- 2.39.2