Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Java Exception not Caught

19 views
Skip to first unread message

brettbirschbach

unread,
Sep 11, 2007, 10:57:39 AM9/11/07
to
Scenario:

Java Classes:
com.pbtest.ParentException extends java.lang.Exception
com.pbtest.ChildException extends com.pbtest.ParentException

PB Proxies:
ParentException extends Exception
ChildException extends ParentException

PB Code:
TRY
// DO SOME JAVA CODE THAT THROWS ChildException
CATCH (ParentException pe)
// Save the day
END TRY

In the above example, if the PB project has ParentException
and ChildException proxies, then PB successfully catches
ChildException as a version of ParentException, and "saves
the day".

However, if I do not have a proxy for ChildException, just
ParentException, PB fails to map the java exception
com.pbtest.ChildException to the PB proxy ParentException.
Is this the expected functionality? I would think, through
the use of Java reflection, PB would be able to find the
ancestor of com.pbtest.ChildException as
com.pbtest.ParentException, and thus map it to the
ParentException PB Proxy. However, it does not appear that
it does so.

Thanks!
-Brett Birschbach

bede

unread,
Sep 12, 2007, 3:26:31 AM9/12/07
to
does it get caught when catching Throwable ?

In article <46e6ace3.57a...@sybase.com>, Brett Birschbach says...

brettbirschbach

unread,
Sep 13, 2007, 6:23:13 PM9/13/07
to
Thanks for the suggestion.

Yes, throwable does work, and it will also get caught when
catching Exception. It appears that if PB cannot map a Java
exception to a Java proxy in your PB code, it maps it to a
generic PB Exception.

The problem is, I don't necessarily want to catch any and
all PowerBuilder exceptions from my TRY/CATCH block. I only
want to catch my Java exception. Any other exceptions can
slip throw and be thrown back to the calling code.
Furthermore, I may have three different java exceptions that
I want to catch, with three different sets of handling code.
If I simply catch Exception, I have no idea which java
exception caused it, and therefore no idea which handling
code to run.

bede

unread,
Sep 17, 2007, 11:54:15 AM9/17/07
to
In that case i would try to workaround as follows:

- use Catch(Throwable t) (highest common ancestor) and try differentiating with t.ClassName()
- alternatively, use the message to make the difference.

however, i do agree that PB should support catching of specific exceptions thrown from within
the java layer. i think it's best to open a case for this.

Since we've been communicating with EJBs before PB supported java, we still use our own way
to communicate errors (returned classes contain an error section).
What is caught as native exceptions is in our case always coming from PBNI or communication
layer. so we don't really have your particular problem.

Good luck & keep us posted,

Ben


In article <46e9b851.22f...@sybase.com>, Brett Birschbach says...

0 new messages