Book a Demo

Author Topic: Retrieving stacktrace  (Read 4074 times)

Henrik Ring

  • EA Novice
  • *
  • Posts: 5
  • Karma: +0/-0
    • View Profile
Retrieving stacktrace
« 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.

Wade Brooks

  • EA Novice
  • *
  • Posts: 15
  • Karma: +0/-0
    • View Profile
Re: Retrieving stacktrace
« Reply #1 on: March 06, 2015, 06:35:12 am »
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
« Last Edit: March 06, 2015, 06:53:21 am by WadeBrooks »

Henrik Ring

  • EA Novice
  • *
  • Posts: 5
  • Karma: +0/-0
    • View Profile
Re: Retrieving stacktrace
« Reply #2 on: March 16, 2015, 08:57:39 pm »
@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
« Last Edit: March 16, 2015, 08:58:46 pm by henrikring »

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: Retrieving stacktrace
« Reply #3 on: March 17, 2015, 12:57:06 am »
Why don't you print to EA's system console?

q.

Henrik Ring

  • EA Novice
  • *
  • Posts: 5
  • Karma: +0/-0
    • View Profile
Re: Retrieving stacktrace
« Reply #4 on: March 18, 2015, 06:59:52 pm »
@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.

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: Retrieving stacktrace
« Reply #5 on: March 18, 2015, 09:11:06 pm »
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.