When writing Java Script Impact Policies I noticed the following:
In the below code example Log(error.stack) seems to only output a truncated stack
trace, which isn't really much use in debugging. I see that I can use error.message,
but that does not give me the same output as if I hadn't bothered with try/catch at
all. It would be nice if error.stack offered full output (see below for
details)?
try {
//some code
}
catch(error) {
Log("An error occured during policy Execution...see stack trace below.");
Log(error.stack);
Log(error.message);
}
finally {
//some code
}
When ran against an example I got the following output:
20 Nov 2020
12:08:41,467: [TEST_TT_MonitorAutoticketJS][pool-2-thread-102283]Parser
log: An error occured during policy Execution...see stack trace below.
Log(error.stack) output: 20 Nov 2020
12:08:41,468: [TEST_TT_MonitorAutoticketJS][pool-2-thread-102283]Parser
log: at pool-2-thread-102283:733 (main)
at pool-2-thread-102283:1069
Log(error.message) output: 20 Nov 2020
12:08:41,468: [TEST_TT_MonitorAutoticketJS][pool-2-thread-102283]Parser
log: com.micromuse.common.util.NetcoolException: Die Datenquelle
NCOMS_SPUx ist nicht vorhanden.
For error.stack I would have expected something like:
20 Nov 2020
12:03:03,691: [TEST_TT_MonitorAutoticketJS][pool-2-thread-102233]Caused
by: org.mozilla.javascript.EcmaError: TypeError: Cannot find function
printStackTrace in object JavaException:
com.micromuse.common.util.NetcoolException: Die Datenquelle NCOMS_SPUx
ist nicht vorhanden.. (pool-2-thread-102233#1082)
org.mozilla.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3951)
org.mozilla.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3929)
org.mozilla.javascript.ScriptRuntime.typeError(ScriptRuntime.java:3962)
org.mozilla.javascript.ScriptRuntime.typeError2(ScriptRuntime.java:3981)
org.mozilla.javascript.ScriptRuntime.notFunctionError(ScriptRuntime.java:4053)
org.mozilla.javascript.ScriptRuntime.getPropFunctionAndThisHelper(ScriptRuntime.java:2425)
org.mozilla.javascript.ScriptRuntime.getPropFunctionAndThis(ScriptRuntime.java:2407)
org.mozilla.javascript.Interpreter.interpretLoop(Interpreter.java:1322)
org.mozilla.javascript.Interpreter.interpret(Interpreter.java:815)
org.mozilla.javascript.InterpretedFunction.call(InterpretedFunction.java:109)
org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:393)
org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:3282)
org.mozilla.javascript.Context.callFunctionWithContinuations(Context.java:1312)
org.mozilla.javascript.Context.executeScriptWithContinuations(Context.java:1279)
com.micromuse.response.common.parser.JavaScriptPolicy.execute(JavaScriptPolicy.java:93)
com.micromuse.response.common.parser.PolicyExecutor.executePolicy(PolicyExecutor.java:150)
com.micromuse.response.common.parser.PolicyExecutor.executePolicy(PolicyExecutor.java:241)
com.micromuse.response.server.MessageProcessor.processMessage(MessageProcessor.java:317)
com.micromuse.response.server.MessageProcessor.processMessage(MessageProcessor.java:257)
com.micromuse.response.server.SynchronousMessageProcessor$1.call(SynchronousMessageProcessor.java:193)
com.micromuse.response.server.SynchronousMessageProcessor$1.call(SynchronousMessageProcessor.java:191)
java.util.concurrent.FutureTask.run(FutureTask.java:277)
com.micromuse.common.util.concurrent.TrackingExecutor$1.run(TrackingExecutor.java:105)
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1160)
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
java.lang.Thread.run(Thread.java:818)