Commit 491a632 1 parent 4ed3566 commit 491a632 Copy full SHA for 491a632
File tree 1 file changed +18
-16
lines changed
1 file changed +18
-16
lines changed Original file line number Diff line number Diff line change @@ -43,32 +43,34 @@ const pipeWithoutStack = <Fs extends Func[]>(
43
43
Fs
44
44
> ;
45
45
46
- const augmentException = ( codeLocation : string ) => ( e : Error ) => {
47
- e . message = ( e . message ? ( e . message + "\n" ) : "" ) + codeLocation ;
48
- return e ;
46
+ // deno-lint-ignore no-explicit-any
47
+ const augmentAndRethrowException = ( location : string ) => ( e : any ) => {
48
+ if ( e === undefined ) {
49
+ console . error ( `undefined error within ${ location } ` ) ;
50
+ throw e ;
51
+ }
52
+ try {
53
+ e . message = ( e . message ? ( e . message + "\n" ) : "" ) + location ;
54
+ } catch ( augmentError ) {
55
+ console . error (
56
+ `error within ${ location } , gamla could not augment error stack` ,
57
+ augmentError ,
58
+ e ,
59
+ ) ;
60
+ }
61
+ throw e ;
49
62
} ;
50
63
51
64
export const errorBoundry = < F extends Func > ( f : F ) => {
52
65
const location = currentLocation ( 4 ) ;
53
- const augment = augmentException ( location ) ;
54
66
return ( ( ...x ) => {
55
67
try {
56
68
const result = f ( ...x ) ;
57
69
return ( isPromise ( result ) )
58
- ? result . catch ( ( e ) => {
59
- if ( e === undefined ) {
60
- console . error ( `undefined error within ${ location } ` ) ;
61
- throw e ;
62
- }
63
- throw augment ( e ) ;
64
- } )
70
+ ? result . catch ( augmentAndRethrowException ( location ) )
65
71
: result ;
66
72
} catch ( e ) {
67
- if ( e === undefined ) {
68
- console . error ( `undefined error within ${ location } ` ) ;
69
- throw e ;
70
- }
71
- throw augment ( e as Error ) ;
73
+ augmentAndRethrowException ( location ) ( e ) ;
72
74
}
73
75
} ) as F ;
74
76
} ;
You can’t perform that action at this time.
0 commit comments