dedmen / ArmaDebugEngine

A still experimental Script Debugger for Arma 3
Other
47 stars 10 forks source link

Suggestion: onScriptError #1

Open Sparker95 opened 5 years ago

Sparker95 commented 5 years ago

Hi!

Since you've asked, I'm making an issue.

Suggestion: add an SQF command: ADE_onScriptError code, which would call my code passed to it on a script error.

It should pass information about the script error to the callback, such as: file, line number, error text, and the callstack itself in string or array form.

Further things to think of: should it be stackable? What if we register the same code variable multiple times?

dedmen commented 5 years ago

should it be stackable?

Honestly I'd just do a single handler thing. Otherwise I need to add tracking, and cleanup, and the ability to remove handlers and handler IDs and ugh.

Returns array callstack [ [file, line, local variables], [file, line, [["va1",val1], ["var2",val2]]], ... ] Order will be either top->bottom or bottom->top whatever is easier. It will still print to RPT. For the local variables we might want to think about making a deep copy of the array after it was built. If the local vars reference arrays they might change between error and the onScriptError handler. Also the handler needs to be spawned as we can't interfere with the script vm while it's processing a error.