Skip to content

Commit c7ca87e

Browse files
committed
[added] <Routes onError>
1 parent c45909a commit c7ca87e

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

modules/components/Routes.js

+8-3
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,8 @@ var Routes = React.createClass({
278278
mixins: [ ActiveContext, LocationContext, RouteContext, ScrollContext ],
279279

280280
propTypes: {
281-
onChange: React.PropTypes.func
281+
onChange: React.PropTypes.func,
282+
onError: React.PropTypes.func
282283
},
283284

284285
getInitialState: function () {
@@ -317,8 +318,12 @@ var Routes = React.createClass({
317318

318319
this.dispatch(path, actionType, function (error, abortReason) {
319320
if (error) {
320-
// Throw so we don't silently swallow errors.
321-
throw error; // This error probably originated in a transition hook.
321+
if (this.props.onError) {
322+
this.props.onError.call(this, error);
323+
} else {
324+
// Throw so we don't silently swallow errors.
325+
throw error; // This error probably originated in a transition hook.
326+
}
322327
} else if (abortReason instanceof Redirect) {
323328
this.replaceWith(abortReason.to, abortReason.params, abortReason.query);
324329
} else if (abortReason) {

0 commit comments

Comments
 (0)