sb123: #i114635# handle non-UNO exceptions in C++ UNO bridge, for unxlngx6, rest to follow

This commit is contained in:
sb
2010-09-21 09:10:04 +02:00
parent 3c525e71d3
commit 0166b35fc6

View File

@@ -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;