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
In article <46e6ace3.57a...@sybase.com>, Brett Birschbach says...
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.
- 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...