1 Get message
Extract the error message from either a native JS object or an instance of throwable:
Copy
try { throw new Ax.lang.Exception("Something wrong happened!"); } catch(e) { const message = Ax.util.Error.getMessage(e); console.log(message); }
Something wrong happened!
2 Get stack trace
Extract the error stack trace from either a native JS object or an instance of throwable:
Copy
try { throw new Ax.lang.Exception("Something wrong happened!"); } catch(e) { const message = Ax.util.Error.getStackTrace(e); console.log(message); }
<STACKTRACE>
deister.axional.script.lib.ax.lang.JSException
at jdk.scripting.nashorn.scripts/jdk.nashorn.internal.scripts.Script$Recompilation$5290$\=main\{d006bed5\}/0x0000000801f10c40.main(memory://main[d006bed5]:4)
at jdk.scripting.nashorn/jdk.nashorn.internal.runtime.ScriptFunctionData.invoke(ScriptFunctionData.java:655)
at jdk.scripting.nashorn/jdk.nashorn.internal.runtime.ScriptFunction.invoke(ScriptFunction.java:513)
at jdk.scripting.nashorn/jdk.nashorn.internal.runtime.ScriptRuntime.apply(ScriptRuntime.java:527)
at jdk.scripting.nashorn/jdk.nashorn.api.scripting.ScriptObjectMirror.callMember(ScriptObjectMirror.java:202)
at jdk.scripting.nashorn/jdk.nashorn.api.scripting.NashornScriptEngine.invokeImpl(NashornScriptEngine.java:393)
at jdk.scripting.nashorn/jdk.nashorn.api.scripting.NashornScriptEngine.invokeFunction(NashornScriptEngine.java:197)
at deister.axional.script.core.engine.impl.AxScriptEngineWrapper.invokeFunction(AxScriptEngineWrapper.java:984)
at deister.axional.script.core.engine.impl.AxScriptEngineWrapper.evalAndInvokeFunction(AxScriptEngineWrapper.java:950)
at deister.axional.script.core.runner.JSScriptRunner.__execute(JSScriptRunner.java:823)
at deister.axional.script.core.runner.JSScriptRunner.execute(JSScriptRunner.java:711)
at deister.axional.script.core.runner.JSScriptRunner.execute(JSScriptRunner.java:642)
at deister.axional.script.core.context.ScriptJDBCConnectionListener.__runScriptAsObject(ScriptJDBCConnectionListener.java:248)
at deister.axional.script.core.context.ScriptJDBCConnectionListener.__runScript(ScriptJDBCConnectionListener.java:222)
at deister.axional.script.core.context.ScriptJDBCConnectionListener.beforeExecute(ScriptJDBCConnectionListener.java:149)
at deister.axional.server.jdbc.JDBCConnectionWrapper.__beforeExecute(JDBCConnectionWrapper.java:1390)
at deister.axional.server.jdbc.JDBCConnectionWrapper.__beforeExecute(JDBCConnectionWrapper.java:1377)
at deister.axional.server.jdbc.JDBCConnectionWrapper.executeScriptOrStatement(JDBCConnectionWrapper.java:3358)
at deister.axional.server.jdbc.session.JDBCSessionExecutionQueue.lambda$executeScriptOrStatement$3(JDBCSessionExecutionQueue.java:156)
at deister.axional.server.jdbc.session.JDBCSessionExecutionQueue.lambda$__doExecution$6(JDBCSessionExecutionQueue.java:214)
at java.base/java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1764)
at java.base/java.util.concurrent.CompletableFuture$AsyncSupply.exec(CompletableFuture.java:1756)
at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:290)
at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1016)
at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1665)
at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1598)
at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:183)
<Root-cause class='class deister.axional.script.lib.ax.lang.JSException'>
</Root-cause>
</STACKTRACE>
3 Get SQL error code
Extracts the SQL error code if the exception is of type SQLException, otherwise returns null
Copy
try { // will throw SQLException let rs = Ax.db.executeQuery('SELECT * FROM xxxx') } catch(e) { const sqlErroCode = Ax.util.Error.getErrorCode(e); console.log(sqlErroCode); }
-206
4 Get SQL state code
Extracts the SQLState if the exception is of type SQLException, otherwise returns null
Copy
try { // will throw SQLException let rs = Ax.db.executeQuery('SELECT * FROM xxxx') } catch(e) { const sqlState = Ax.util.Error.getSQLState(e); console.log(sqlState); }
42000