In suitescript 2.1 is anyone else having trouble g...
# suitescript
d
In suitescript 2.1 is anyone else having trouble getting the stacktrace back from the exception object in a try/catch? In 2.0 we could stringify the exception and get all the useful information for logging (message, file, line, stacktrace, etc). In 2.1 we just get an empty object.
// debugger script try { var x = foo.breakme; } catch(ex) { log.debug(JSON.stringify(ex)); } // 2.0 output debug {"message":"\"foo\" is not defined.","fileName":"adhoc$-1$debugger.user","lineNumber":2,"name":"ReferenceError","stack":"\tat adhoc$-1$debugger.user:2\n","rhinoException":{}} 8/23/2021 093520.725 // 2.1 output {} COMPLETED SCRIPT EXECUTION metrics usage 0, time 6678ms 08/23/2021 093555.839
s
do you get anything if you explicitly log
ex.stack
?
b
d
Interesting. Yes, ex.stack does give me the stack. The link by battk explains why. How do we access the rest of the error properties?
ex.stack returns ReferenceError: foo is not defined at Object.<anonymous> (<eval>:2)
but ex.fileName is undefined?
s
what I'd recommend you try is logging
_.toPlainObject(ex)
b
the errors thrown by 2.1 and 2.0 arent the same error
there is no fileName on the 2.1 error
d
This is the Error link from the documentation in the link above. So does this mean in 2.1 if an error happens in a catch name and message are the only values available? That doesn't seem very useful?
b
should be a stack in there too
all javascript engines have a stack in their errors
they may disagree on whether that stack should be a string or an array of strings
d
The link shows it as non-standard but as long as it continues working I guess all the data is still there.
Thanks guys that helped me get going again.