This repository was archived by the owner on Apr 20, 2018. It is now read-only.
File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11 var errorObj = { e : { } } ;
2- var tryCatchTarget ;
3- function tryCatcher ( ) {
4- try {
5- return tryCatchTarget . apply ( this , arguments ) ;
6- } catch ( e ) {
7- errorObj . e = e ;
8- return errorObj ;
2+ function tryCatcherGen ( tryCatchTarget ) {
3+ return function tryCatcher ( ) {
4+ try {
5+ return tryCatchTarget . apply ( this , arguments ) ;
6+ } catch ( e ) {
7+ errorObj . e = e ;
8+ return errorObj ;
9+ }
910 }
1011 }
11- function tryCatch ( fn ) {
12+ var tryCatch = Rx . internals . tryCatch = function tryCatch ( fn ) {
1213 if ( ! isFunction ( fn ) ) { throw new TypeError ( 'fn must be a function' ) ; }
13- tryCatchTarget = fn ;
14- return tryCatcher ;
14+ return tryCatcherGen ( fn ) ;
1515 }
1616 function thrower ( e ) {
1717 throw e ;
Original file line number Diff line number Diff line change 1+ QUnit . module ( 'tryCatch' ) ;
2+
3+ var tryCatch = Rx . internals . tryCatch ;
4+
5+ test ( 'tryCatch_multiple' , function ( ) {
6+ var catcher1 = tryCatch ( function ( ) { return 1 ; } ) ;
7+ var catcher2 = tryCatch ( function ( ) { return 2 ; } ) ;
8+
9+ ok ( catcher1 ( ) === 1 , "Shouldn't store state in global context" ) ;
10+ ok ( catcher2 ( ) === 2 , "Shouldn't store state in global context" ) ;
11+ } ) ;
Original file line number Diff line number Diff line change 9595
9696 <!-- Individual Tests -->
9797 < script src ="internal/isequal.js "> </ script >
98+ < script src ="internal/trycatch.js "> </ script >
9899 < script src ="subjects/asyncsubject.js "> </ script >
99100 < script src ="subjects/subject.js "> </ script >
100101
You can’t perform that action at this time.
0 commit comments