From c7ca87e1d42983f63d3e7a6a1259d6b9fd347bb1 Mon Sep 17 00:00:00 2001 From: Michael Jackson Date: Wed, 8 Oct 2014 20:56:32 -0700 Subject: [PATCH] [added] --- modules/components/Routes.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) 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) {