Stacktrace for Cloud Code errors?
-
Is there a way to get a full stacktrace for errors?
Especially when using bridge.include, it is possible to have deeply nested logic which makes it very difficult to track down the code path that caused the errors.
I have some code that works locally (node.js env), but not in Rhino, it seems:
const Assert = {}; function stackTrace() { var err = new Error(); return err.stack; } Assert.assert = function(expr, message){ if ( !expr ){ console.log(stackTrace()); throw message; } };
Thanks,
Travis -
I'm interested in this too! I tried a few things that didn't seem to work. Since there's no "step through" like GameSparks, for example, gotta rely on stacktraces for fast debugging.
I find myself devving a bit slow when I have errs due to no stacktraces. Or ... is there a way?
-
It looks like the next Rhino release may have some extra support for us there. We will look to enable it once it's available.
-
@Paul-Winterhalder fingers crossed
-
I was just looking into this the other day, too! Like most issues in cloud script, it's a Rhino issue - you never know what isn't fully implemented, and the lacking IDE features doesn't let you know.
What I did was ghetto, but it worked. In every script, I make an array that tracks stacktrace, then I try/catch everything. I rethrow until I get to my main func, where I funnel it to an err handler.
It looks like the next Rhino release may have some extra support for us there. We will look to enable it once it's available.
The new Rhino release (already out) will even add
${}
templating and backtick support~ -
Well - the new release isn't out yet - it's just a Release Candidate.
https://github.com/mozilla/rhino/releases
That said - we are very happy to see the progress - since it has been over a year since 1.7.13 was released!
Hopefully soon!