简体   繁体   中英

Getting the line number or full stack trace on exceptions in a gremlin-groovy script

I have a gremlin-groovy script that traverses a database which is incredibly noisy. There are lots of cases with missing edges or properties. When I assume an edge or property exists and it doesn't an exception is thrown I get a very simple output like this:

javax.script.ScriptException: java.util.IllegalFormatConversionException: d != java.lang.String

I'd like to make it so when the script encounters a fatal exception, as the one above, it provides a stack dump or at least a line number so I can debug where it happened, similar to how java can print a full stack trace on fatal exceptions.

Any suggestions on how to get a better dump?

I recommend using the Gremlin terminal for this.

gremlin$ ./gremlin.sh

         \,,,/
         (o o)
-----oOOo-(_)-oOOo-----
gremlin> a bad thing
No such property: bad for class: groovysh_evaluate
Display stack trace? [yN] y
groovy.lang.MissingPropertyException: No such property: bad for class: groovysh_evaluate
    at     org.codehaus.groovy.runtime.ScriptBytecodeAdapter.unwrap(ScriptBytecodeAdapter.java:50)

If you don't have this luxury (eg via a REST server), then you may want to place some intelligent 'printlns' in your traversal.

my.long.traversal.sideEffect{println 'I am here'}.is.very.long

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM