Hi,
I'm running a series of named queries using scripting. I've put try-except statements around most of my named queries, but it doesn't appear to be catching the error from the actual named query e.g. Table is missing or Database is offline
I had the query in question set to query not update changed that and didn't fix it but adding the throwable section did now i'm getting what i expected from the error handling.
Do you happen to know why I need the throwable code instead of a regular exception?
To be more precise, java exceptions and jython exceptions are not in the same class hierarchy, so an except clause that names an exception type cannot catch from the other hierarchy. You need two except clauses in some cases.
Yes, but then you cannot easily use the backtrace-handling logger methods. And if you are going to throw away the backtrace, what's the point of catching any generic exception?
If you aren't going to ignore the exception entirely (or expected exceptions for which you have specific handling), then you really want the proper backtrace.
If you want to handle some exceptions and then log the generic ones, use three or more except clauses. The last two should be the jython and java generics, and the jython generic should be converted to java for the logger.
High on my scripting wish list is extending LoggerEx methods to accept Jython throwables and transparently adapt their stacktrace to the right format. That way logging either branch of exception 'just works' (if you've structured your catch the right way).