Skip to content

Commit

Permalink
Better error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
SachaG committed Dec 14, 2020
1 parent 3ac6776 commit 74fc9dc
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
4 changes: 2 additions & 2 deletions packages/vulcan-debug/lib/components/ErrorCatcherContents.jsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import React from 'react';
import { Components, replaceComponent } from 'meteor/vulcan:lib';

const ErrorCatcherContents = ({ error }) => (
const ErrorCatcherContents = ({ error, message }) => (
<div className="error-catcher">
<Components.Flash message={{ id: 'errors.generic_report', properties: { errorMessage: error.message } }} />
<Components.Flash message={{ id: 'errors.generic_report', message, properties: { error } }} />
<div className="error-catcher-help">
<p>Here are some suggestions to help you fix this issue:</p>
<ol>
Expand Down
10 changes: 6 additions & 4 deletions packages/vulcan-errors/lib/components/ErrorCatcher.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ import { withRouter } from 'react-router';
import React, { Component } from 'react';
import { Errors } from '../modules/errors.js';

const getMessage = error => error.message || error.errorMessage;

class ErrorCatcher extends Component {
state = {
error: null,
Expand All @@ -25,7 +27,7 @@ class ErrorCatcher extends Component {
const { sourceVersion } = siteData;
this.setState({ error });
Errors.log({
message: error.message,
message: getMessage(error),
error,
details: { ...errorInfo, sourceVersion },
currentUser,
Expand All @@ -47,15 +49,15 @@ class ErrorCatcher extends Component {

render() {
const { error } = this.state;
return error ? <Components.ErrorCatcherContents error={error} /> : this.props.children;
return error ? <Components.ErrorCatcherContents error={error} message={getMessage(error)} /> : this.props.children;
}
}

registerComponent('ErrorCatcher', ErrorCatcher, withCurrentUser, withSiteData, withRouter);

const ErrorCatcherContents = ({ error }) => (
const ErrorCatcherContents = ({ error, message }) => (
<div className="error-catcher">
<Components.Flash message={{ id: 'errors.generic_report', properties: { errorMessage: error.message } }} />
<Components.Flash message={{ id: 'errors.generic_report', message, properties: error }} />
</div>
);

Expand Down

0 comments on commit 74fc9dc

Please sign in to comment.