File tree Expand file tree Collapse file tree 2 files changed +18
-1
lines changed
Expand file tree Collapse file tree 2 files changed +18
-1
lines changed Original file line number Diff line number Diff line change @@ -93,7 +93,7 @@ export class TransitionHook {
9393 try {
9494 results . push ( hooks [ i ] . invokeStep ( locals ) ) ;
9595 } catch ( exception ) {
96- if ( ! swallowExceptions ) throw exception ;
96+ if ( ! swallowExceptions ) return REJECT . aborted ( exception ) ;
9797 console . log ( "Swallowed exception during synchronous hook handler: " + exception ) ; // TODO: What to do here?
9898 }
9999 }
Original file line number Diff line number Diff line change @@ -123,6 +123,23 @@ describe('transition', function () {
123123 expect ( result . get ( ) . reject . message ) . toEqual ( "transition failed" ) ;
124124 } ) ) ;
125125
126+ it ( '$transition$.promise should reject on error in synchronous hooks' , inject ( function ( $transitions , $q ) {
127+ var result = new PromiseResult ( ) ;
128+
129+ transitionProvider . onBefore ( { from : "*" , to : "third" } , function ( $transition$ ) {
130+ result . setPromise ( $transition$ . promise ) ;
131+ throw new Error ( "transition failed" ) ;
132+ } ) ;
133+
134+ try {
135+ makeTransition ( "" , "third" ) . run ( ) ;
136+ } catch ( e ) { }
137+ $q . flush ( ) ;
138+
139+ expect ( result . called ( ) ) . toEqual ( { resolve : false , reject : true , complete : true } ) ;
140+ expect ( result . get ( ) . reject . detail . message ) . toEqual ( "transition failed" ) ;
141+ } ) ) ;
142+
126143 it ( 'should inject $transition$' , inject ( function ( $transitions , $q ) {
127144 var t = null ;
128145
You can’t perform that action at this time.
0 commit comments