Skip to content

Commit

Permalink
[added] <Routes onError>
Browse files Browse the repository at this point in the history
  • Loading branch information
mjackson committed Oct 9, 2014
1 parent c45909a commit c7ca87e
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions modules/components/Routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 () {
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit c7ca87e

Please sign in to comment.