diff options
author | sb <sb@openoffice.org> | 2010-09-21 09:10:04 +0200 |
---|---|---|
committer | sb <sb@openoffice.org> | 2010-09-21 09:10:04 +0200 |
commit | 0166b35fc660911c02d56852fca79f89e7cede5c (patch) | |
tree | 9a2a0641917442136d6d65913f5e41766f18e58a /bridges | |
parent | 3c525e71d317c8e00f27eb557d1c129395513546 (diff) |
sb123: #i114635# handle non-UNO exceptions in C++ UNO bridge, for unxlngx6, rest to follow
Diffstat (limited to 'bridges')
-rw-r--r-- | bridges/source/cpp_uno/gcc3_linux_x86-64/uno2cpp.cxx | 49 |
1 files changed, 42 insertions, 7 deletions
diff --git a/bridges/source/cpp_uno/gcc3_linux_x86-64/uno2cpp.cxx b/bridges/source/cpp_uno/gcc3_linux_x86-64/uno2cpp.cxx index 6a9ab16845dc..5bcdf8c2497a 100644 --- a/bridges/source/cpp_uno/gcc3_linux_x86-64/uno2cpp.cxx +++ b/bridges/source/cpp_uno/gcc3_linux_x86-64/uno2cpp.cxx @@ -28,10 +28,14 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_bridges.hxx" +#include <exception> +#include <typeinfo> #include <stdio.h> #include <stdlib.h> #include <string.h> -#include <rtl/alloc.h> + +#include "rtl/alloc.h" +#include "rtl/ustrbuf.hxx" #include <com/sun/star/uno/genfunc.hxx> #include "com/sun/star/uno/RuntimeException.hpp" @@ -237,6 +241,18 @@ static void callVirtualMethod(void * pThis, sal_uInt32 nVtableIndex, //================================================================================================== +namespace { + +void appendCString(OUStringBuffer & buffer, char const * text) { + if (text != 0) { + buffer.append( + OStringToOUString(OString(text), RTL_TEXTENCODING_ISO_8859_1)); + // use 8859-1 to avoid conversion failure + } +} + +} + static void cpp_call( bridges::cpp_uno::shared::UnoInterfaceProxy * pThis, bridges::cpp_uno::shared::VtableSlot aVtableSlot, @@ -369,12 +385,31 @@ static void cpp_call( try { - callVirtualMethod( - pAdjustedThisPtr, aVtableSlot.index, - pCppReturn, pReturnTypeRef, bSimpleReturn, - pStackStart, ( pStack - pStackStart ), - pGPR, nGPR, - pFPR, nFPR ); + try { + callVirtualMethod( + pAdjustedThisPtr, aVtableSlot.index, + pCppReturn, pReturnTypeRef, bSimpleReturn, + pStackStart, ( pStack - pStackStart ), + pGPR, nGPR, + pFPR, nFPR ); + } catch (Exception &) { + throw; + } catch (std::exception & e) { + OUStringBuffer buf; + buf.appendAscii(RTL_CONSTASCII_STRINGPARAM("C++ code threw ")); + appendCString(buf, typeid(e).name()); + buf.appendAscii(RTL_CONSTASCII_STRINGPARAM(": ")); + appendCString(buf, e.what()); + throw RuntimeException( + buf.makeStringAndClear(), Reference< XInterface >()); + } catch (...) { + throw RuntimeException( + OUString( + RTL_CONSTASCII_USTRINGPARAM( + "C++ code threw unknown exception")), + Reference< XInterface >()); + } + // NO exception occured... *ppUnoExc = 0; |