@@ -189,6 +189,11 @@ function queryIsActive(activeQuery, query) {
189
189
return true ;
190
190
}
191
191
192
+ function defaultTransitionErrorHandler ( error ) {
193
+ // Throw so we don't silently swallow async errors.
194
+ throw error ; // This error probably originated in a transition hook.
195
+ }
196
+
192
197
/**
193
198
* The <Routes> component configures the route hierarchy and renders the
194
199
* route matching the current location when rendered into a document.
@@ -205,13 +210,14 @@ var Routes = React.createClass({
205
210
initialPath : React . PropTypes . string ,
206
211
initialMatches : React . PropTypes . array ,
207
212
onChange : React . PropTypes . func ,
208
- onError : React . PropTypes . func
213
+ onError : React . PropTypes . func . isRequired
209
214
} ,
210
215
211
216
getDefaultProps : function ( ) {
212
217
return {
213
218
initialPath : null ,
214
- initialMatches : [ ]
219
+ initialMatches : [ ] ,
220
+ onError : defaultTransitionErrorHandler
215
221
} ;
216
222
} ,
217
223
@@ -267,12 +273,7 @@ var Routes = React.createClass({
267
273
268
274
this . dispatch ( path , function ( error , abortReason , nextState ) {
269
275
if ( error ) {
270
- if ( this . props . onError ) {
271
- this . props . onError . call ( this , error ) ;
272
- } else {
273
- // Throw so we don't silently swallow errors.
274
- throw error ; // This error probably originated in a transition hook.
275
- }
276
+ this . props . onError . call ( this , error ) ;
276
277
} else if ( abortReason instanceof Redirect ) {
277
278
this . replaceWith ( abortReason . to , abortReason . params , abortReason . query ) ;
278
279
} else if ( abortReason ) {
0 commit comments