Re: [Py4j-users] way to access java exceptions in python
Status: Beta
Brought to you by:
barthe
From: Barthelemy D. <ba...@cs...> - 2011-01-21 13:03:07
|
Hi, I agree with you, exceptions in some Java Library/Framework carry important information that should be available on the Python side. Py4J could wrap the Java Exception in the Py4JJavaError exception, a new class extending Py4JError. Something like: try: ... except Py4JJavaError as e: javaException = e.getJavaException() That would allow clients to differentiate between catching Java exceptions and catching Py4J exceptions (e.g., misuse of the library, network error, etc.). Clients could still use the catch all: except Py4JError: to catch any exception raised while using Py4J, Java exceptions included. I just need to make sure that there is no Python black magic that prevents the Python exception from being garbage collected. Would that work with your use case? Barthélémy On 01/21/2011 06:42 AM, Jakub Gustak wrote: > I would like to propose a enhancement to a py4j. > > Right now the only way to get any info about java side exception is to > parse a error message string. > It would be quite convenient to be able to access the original java > exception object. > > As far as I understand the code it would require ReturnObject which > would be a hybrid of error and reference. > Is there any java side limitation than can make it hard to achieve? > > Best regards, > Jakub > > ------------------------------------------------------------------------------ > Special Offer-- Download ArcSight Logger for FREE (a $49 USD value)! > Finally, a world-class log management solution at an even better price-free! > Download using promo code Free_Logger_4_Dev2Dev. Offer expires > February 28th, so secure your free ArcSight Logger TODAY! > http://p.sf.net/sfu/arcsight-sfd2d > _______________________________________________ > Py4j-users mailing list > Py4...@li... > https://lists.sourceforge.net/lists/listinfo/py4j-users |