File tree Expand file tree Collapse file tree 2 files changed +33
-9
lines changed Expand file tree Collapse file tree 2 files changed +33
-9
lines changed Original file line number Diff line number Diff line change @@ -41,17 +41,41 @@ export async function callFunctionOn(
4141 ctx = objManager . getObj ( objectId )
4242 }
4343
44- let object = await callFn ( functionDeclaration , args , ctx ) ;
45- let result = objManager . wrap ( object , {
46- generatePreview : true ,
47- } ) ;
48- if ( params . returnByValue ) {
49- result . value = structuredClone ( object ) ;
44+ let object ;
45+ let exception ;
46+ let threw = false ;
47+ try {
48+ object = await callFn ( functionDeclaration , args , ctx ) ;
49+ } catch ( e ) {
50+ exception = e ;
51+ threw = true ;
5052 }
5153
52- return {
53- result,
54+ const ret : any = { } ;
55+
56+ if ( threw ) {
57+ ret . exceptionDetails = {
58+ exceptionId : 1 ,
59+ text : "Uncaught" ,
60+ lineNumber : 0 , // TODO
61+ columnNumber : 0 , // TODO
62+ stackTrace : { callFrames : [ ] } , // TODO
63+ exception : objManager . wrap ( exception , {
64+ generatePreview : true ,
65+ } )
66+ } ;
67+ } else {
68+ const result = objManager . wrap ( object , {
69+ generatePreview : true ,
70+ } ) ;
71+ if ( params . returnByValue ) {
72+ result . value = structuredClone ( object ) ;
73+ }
74+
75+ ret . result = result ;
5476 }
77+
78+ return ret
5579}
5680
5781let isEnable = false
Original file line number Diff line number Diff line change @@ -333,7 +333,7 @@ function getDescription(obj: any, self: any = obj) {
333333 } else if ( subtype === 'regexp' ) {
334334 description = toStr ( obj )
335335 } else if ( subtype === 'error' ) {
336- description = obj . stack
336+ description = obj . message + obj . stack ;
337337 } else if ( subtype === 'internal#entry' ) {
338338 if ( obj . name ) {
339339 description = `{"${ toStr ( obj . name ) } " => "${ toStr ( obj . value ) } "}`
You can’t perform that action at this time.
0 commit comments