1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #ifndef _CPPUHELPER_EXC_HLP_HXX_
21 #define _CPPUHELPER_EXC_HLP_HXX_
23 #include <com/sun/star/uno/Any.hxx>
24 #include "cppuhelperdllapi.h"
29 /** This function throws the exception given by rExc. The given value has to
30 be of typeclass EXCEPTION and must be dervived from or of
31 type com.sun.star.uno.Exception.
34 exception to be thrown.
36 CPPUHELPER_DLLPUBLIC
void SAL_CALL
throwException( const ::com::sun::star::uno::Any
& rExc
)
37 SAL_THROW( (::com::sun::star::uno::Exception
) );
39 /** Use this function to get the dynamic type of a caught C++-UNO exception;
40 completes the above function throwing exceptions generically.
47 catch (::com::sun::star::uno::RuntimeException &)
49 // you ought not handle RuntimeExceptions:
52 catch (::com::sun::star::uno::Exception &)
54 ::com::sun::star::uno::Any caught( ::cppu::getCaughtException() );
60 - use only for caught C++-UNO exceptions (UNOIDL defined)
61 - only as first statement in a catch block!
62 - don't do a C++ rethrow (throw;) after you have called this function
63 - call getCaughtException() just once in your catch block!
64 (function internally uses a C++ rethrow)
70 This function is limited to the same C++ compiler runtime library.
71 E.g. for MSVC, this means that the catch handler code (the one
72 that calls getCaughtException()) needs to use the very same
73 C++ runtime library, e.g. msvcrt.dll as cppuhelper, e.g.
74 cppuhelper3MSC.dll and the bridge library, e.g. msci_uno.dll.
75 This is the case if all of them are compiled with the same
77 Background: The msci_uno.dll gets a rethrown exception out
78 of the internal msvcrt.dll thread local storage (tls).
79 Thus you _must_ not use this function if your code needs to run
80 in newer UDK versions without being recompiled, because those
81 newer UDK (-> OOo versions) potentially use newer C++ runtime
82 libraries which most often become incompatible!
84 But this function ought to be usable for most OOo internal C++-UNO
85 development, because the whole OOo code base is compiled using the
86 same C++ compiler (and linking against one runtime library).
88 CPPUHELPER_DLLPUBLIC ::com::sun::star::uno::Any SAL_CALL
getCaughtException();
94 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */