Apache OpenOffice (AOO) Bugzilla – Issue 83978
Basic runtime: unpack multiple WrappedTargetException errors, and error handling consolidation
Last modified: 2013-02-24 21:00:38 UTC
Invoking, from within Basic, a method in a component of mine which throws a WrappedTargetException, I found it somewhat unfortunate that the Basic IDE only shows the message of the WrappedTargetException (which is of limited use to the user, as it is often the case with "wrapping" exceptions), but not the message of the exception which was actually wrapped. Thus, I here propose a fix to the sbunoobj.cxx file, which actually unpacks a "chain" of WrappedTargetExceptions. That is, if the WrappedTargetException.TargetException member is a WrappedTargetException itself, then it will also be handled, and so on. For this, the patch modifies implHandleWrappedTargetException: - first, if the exception is an InvocationTargetException, it is completely ignored. Note that this is what the old code does with completely ignoring any WrappedTargetException's message, silently assuming that it is always an InvocationTargetException. - then, the message of the WrappedTargetException is appended to a string buffer. - If the TargetException member of the error is also a WrappedTargetException, it continues with the previous step. - If there is no WrappedTargetException anymore, but TargetException still contains an Exception object, this object's message is also appended. - The special handling for BasicErrorException instances was preserved: "Traveling" the chain of WrappedTargetException's finishes if such a BasicErrorException is encountered. Also, while I changed the code, I noticed there's a lot of duplicate code in the exception handling, basically multiple catch ( FooException& e1 ) { handleFooException( e1 ); } catch( BarException& e2 ) { handleBarException( e2 ); } ... blocks. Since there today exists a "::cppu::getCaughtException()", I took the liberty to consolidate those blocks into single catch( const Exception& ) { handleAnyException( ::cppu::getCaughtException() ); } blocks. In the same course, the String implGetExceptionMsg( Exception& e ) was replaced with template< class EXCEPTION > String implGetExceptionMsg( const EXCEPTION& e ) , which means we now always display the type of the caught exception.
Created attachment 49908 [details] patch
fs: Andreas is currently on vacation. He will take care of the patch when he is returned.
wrong component
ab->fs: Sounds very good, Thanks :-) STARTED, OOo 2.4, -> cws ab42
FIXED
ab->jsk: Please verify It's difficult to verify this issue in detail as a big part is just code clean up. But of course the exception error display should still work, e.g.: Sub Main BasicLibraries.LoadLibrary( "ThisLibDoesNotExist" ) End Sub should display: BASIC runtime error An exception occured Type: com.sun.star.container.NoSuchElementException Message: .
Exceptionally verified.
Closed