diff --git a/modules/components/Routes.js b/modules/components/Routes.js index 18abbd826c..260f180a80 100644 --- a/modules/components/Routes.js +++ b/modules/components/Routes.js @@ -278,7 +278,8 @@ var Routes = React.createClass({ mixins: [ ActiveContext, LocationContext, RouteContext, ScrollContext ], propTypes: { - onChange: React.PropTypes.func + onChange: React.PropTypes.func, + onError: React.PropTypes.func }, getInitialState: function () { @@ -317,8 +318,12 @@ var Routes = React.createClass({ this.dispatch(path, actionType, function (error, abortReason) { if (error) { - // Throw so we don't silently swallow errors. - throw error; // This error probably originated in a transition hook. + if (this.props.onError) { + this.props.onError.call(this, error); + } else { + // Throw so we don't silently swallow errors. + throw error; // This error probably originated in a transition hook. + } } else if (abortReason instanceof Redirect) { this.replaceWith(abortReason.to, abortReason.params, abortReason.query); } else if (abortReason) {