Sparx Systems Forum
Enterprise Architect => Automation Interface, Add-Ins and Tools => Topic started by: Henrik Ring on March 05, 2015, 12:03:01 am
-
Is there any way to retrieve the stack trace in EA scripts written in JScript/Javascript?
// Somehow retrieve stack trace as string to be logged eg. something like:
try {
functionThatCausesExceptionWhenCalled();
} catch (e) {
LOGError(e.message + "\n" + myGetStackTraceAsStringFunction(e) )
}
I can get the stack trace when I debug, but I wish to write the stack trace to the log in case a script fails when running in "none debug" mode.
-
you can redirect stdout or stderr to a file.
here is an example of stderr:
script --option parameter 2> error.log
The command shell will start "script" pass options and parameters to the program. The "2> error.log" would be removed by the shell and error output would be directed into the error.log file
-
@Wade,
I am running the script from within the context of EA not at at the command line. Could be a script initiated through a right click on an item in the project browser then navigating "Scripts > MyScript".
best regards,
Henrik
-
Why don't you print to EA's system console?
q.
-
@qwerty
Yes that will also be helpful. Do you know of a way I can print the stack trace to the system console when not running i debug mode?
Could be something similar to Javas printStackTrace() method.
-
Unfortunately I'm not that familiar with JScript. Probably a method to redirect the stack trace to a string and then send that to EA's console?
q.