]> git.localhorst.tv Git - alttp.git/commitdiff
improved error reporting
authorDaniel Karbach <daniel.karbach@localhorst.tv>
Wed, 15 Feb 2023 10:36:47 +0000 (11:36 +0100)
committerDaniel Karbach <daniel.karbach@localhorst.tv>
Wed, 15 Feb 2023 10:36:47 +0000 (11:36 +0100)
resources/js/components/common/ErrorBoundary.js
resources/js/components/common/ErrorMessage.js

index 4fbc562efd8a82a015a90f376693962b0062fa94..83fdb3e3c6c3035ee596f0987229d23469ad1eaf 100644 (file)
@@ -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 <p>error</p>;
+                       return <ErrorMessage error={error} />;
                }
                return children;
        }
index 8829de7a46f109706c042e32f2a8464876d0791e..2430bc24199de6ee13629a342d54d9efe0ad5db9 100644 (file)
@@ -12,6 +12,12 @@ const ErrorMessage = ({ error }) => {
                        <p className="mb-0">{i18n.t(`error.${error.response.status}.description`)}</p>
                </Alert>;
        }
+       if (error.message) {
+               return <Alert variant="danger">
+                       <Alert.Heading>Error</Alert.Heading>
+                       <p className="mb-0">{error.message}</p>
+               </Alert>;
+       }
        return <div className="error">Error</div>;
 };