return method stack on error?

Hi all,

We use a global method to handle all errors that occur in the solution.
If an error occurs we create a record in a logtable so we’ll be able to get a better idea of what a user runs into.
We already store information about the context (forms/mode/record id etc. ) the solution was in when the error occurred.

An even better logging could be achieved if we could have a look at the method stack at that particular moment.
Is there any chance this info can be retrieved?

Thnkx

for rhino/scripting exceptions you can do:

ex.getScriptStackTrace()

but this will not work for all kind of exceptions you could get.

i could add for 6 also that one for ServoyExceptions, but that will not give back the script stack as above (that info is only there in script exceptions)

thnkx Johan, this will help a lot!!!

in 6 we already now have getStackTrace() for none script exceptions
so there you can do now

var trace = "";
if (ex.getScriptStackTrace) trace = ex.getScriptStackTrace();
else if (ex.getStackTrace)  trace = ex.getStackTrace();

so with the first you get the actual script stack trace and with the second the java full blown stacktrace.

jcompagner:
so with the first you get the actual script stack trace and with the second the java full blown stacktrace.

blow me away! :wink:

Just implemented the first part and that gives me already good detailed information.
Please remind me to implement the new stuff in 6 once it’s released… :lol:

mboegem:
Just implemented the first part and that gives me already good detailed information.

Now that I’m running this code in smartclient I don’t get the stacktrace returned using ex.getScriptStackTrace();.
When I run the same method including error in debug client it works fine.

Is this expected behaviour or did I miss something?

i guess we are then in compiled mode and rhino can’t then give you that information.
i guess the stack trace that you maybe see in the log has those “c1” (or c2, any number) classes in its trace?

don’t know exactly what you mean with c1/c2.

This is what the debug client returns on the error:
org.mozilla.javascript.EcmaError: ReferenceError: “x” is not defined. (C:\Servoy_All\Workspaces\5.0.0_dev\navigation\globals.js#664)

	at C:\Servoy_All\Workspaces\5.0.0_dev\navigation\globals.js:664 (nav_dc_add)
	at C:\Servoy_All\Workspaces\5.0.0_dev\crm\forms\Address_methods.js:190 (onSort)
	at C:\Servoy_All\Workspaces\5.0.0_dev\crm\forms\Address_stbl.js:16 (onSort)

Anyway, it would be very nice to have this kind of information returned in normal clients as well.
This will help a lot to find out where the user went wrong.
A lot of our methods are called from other methods, this can be numberous levels deep. Every level of course depending on its own arguments.

Hi guys,

Is there a way to get the method call stack at any given moment at runtime without throwing an error?
I’d like to log the stack trace when I audit fields in my app but I’m not sure how to get it (he script stack trace, not java).

Cheers!
Maria