How to view full error text when truncated

Hi all
I'm getting the following error message but it's truncated and I can't work out how to get the whole thing to show/ copy into a text editor.

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.

2 Likes

I have no idea where that tooltip screenshot is coming from, but have you checked your console?

1 Like

I'll give that a bash @lrose , thanks!

I have checked the console, yes. It is for some reason very choosy about what errors it decides to report.
These ones are not there.

This is just good practice anyways fyi OP. Any business logic should be done in a try/except and with appropriate steps logged, errors logged.

1 Like

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.

1 Like

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.

Your line

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.

Also here's a rough start.

from java.lang import Throwable
#snip
try:
    #bla
except Throwable, t:
    logger.error(t)
except Exception, e:
    logger.error(system.reflection.asThrowable(e))

  1. Technically it's referring to a code object not the definition but I'm keeping it simple. â†Šī¸Ž

4 Likes

Thanks @Felipe_CRM , I shall try again :slight_smile:

Perfect! That's got what I need dropping into the logs :smiley:
Thank you!