I've tried clicking on the ellipses, but that doesn't seem to do anything, and neither does clicking on the red triangle in the property editor.
Please use step by step directions and small words...
Unfortunately, there isn't a good way to get to it from the designer.
Surround the calling code getAnyBatchesAvailable() with a Try...Except, being sure to catch both the Python Exception and the java.lang.Throwable
Something like:
from java.lang import Throwable
myLogger = system.util.getLogger("MyLoggerName")
#some code
try:
getAnyBatchesAvailable()
except e as Exception:
myLogger.infof("There was an errror! %s", e.cause)
except t as java.lang.Throwable:
myLogger.info(t)
#the rest of the code
Then you will be able to find the error message in the Logs on the Gateway.
This is a bad practice. Not all exceptions are layered with a chain of causes, and when not, that construct will entirely miss the real reason. Use the LoggerEx methods that take a Throwable to dump complete tracebacks into the logs. Use later.PythonAsJavaException or system.reflection.asThrowable() to make Jython exceptions logger-compatible.
Hi @pturmel
Thank you for this, and for the links. I have the Integration Toolkit, but I'm struggling to put this all together to actually drop anything into the logger.
The closest I'm getting is:
try:
ds = RailManagement.outload.getAnyBatchesAvailable()
except:
t = Throwable.getCause
logger.info(str(t))
which is just sending <java function getCause 0x384b03a>
(so it's doing something, I suppose).
Could I impose upon you for pseudocode or syntax assistance, please?
Thanks.
Is referring to the actual getCause function definition of the actual class definition Throwable. [1]
You want to catch a particular exception and then log it.
Pturmel's later.py actually has some examples on how you would use it.