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 INCLUDED_CPPUHELPER_EXC_HLP_HXX
21 #define INCLUDED_CPPUHELPER_EXC_HLP_HXX
23 #include "com/sun/star/uno/Any.hxx"
24 #include "cppuhelper/cppuhelperdllapi.h"
29 /** This function throws the exception given by rExc. The given value has to
30 be of typeclass EXCEPTION and must be derived from or of
31 type com.sun.star.uno.Exception.
34 exception to be thrown.
36 CPPUHELPER_DLLPUBLIC
void SAL_CALL
throwException( const css::uno::Any
& rExc
);
38 /** Use this function to get the dynamic type of a caught C++-UNO exception;
39 completes the above function throwing exceptions generically.
46 catch (css::uno::RuntimeException &)
48 // you ought not handle RuntimeExceptions:
51 catch (css::uno::Exception &)
53 css::uno::Any caught( ::cppu::getCaughtException() );
59 - use only for caught C++-UNO exceptions (UNOIDL defined)
60 - only as first statement in a catch block!
61 - don't do a C++ rethrow (throw;) after you have called this function
62 - call getCaughtException() just once in your catch block!
63 (function internally uses a C++ rethrow)
69 This function is limited to the same C++ compiler runtime library.
70 E.g. for MSVC, this means that the catch handler code (the one
71 that calls getCaughtException()) needs to use the very same
72 C++ runtime library, e.g. msvcrt.dll as cppuhelper, e.g.
73 cppuhelper3MSC.dll and the bridge library, e.g. msci_uno.dll.
74 This is the case if all of them are compiled with the same
76 Background: The msci_uno.dll gets a rethrown exception out
77 of the internal msvcrt.dll thread local storage (tls).
78 Thus you _must_ not use this function if your code needs to run
79 in newer UDK versions without being recompiled, because those
80 newer UDK (-> OOo versions) potentially use newer C++ runtime
81 libraries which most often become incompatible!
83 But this function ought to be usable for most OOo internal C++-UNO
84 development, because the whole OOo code base is compiled using the
85 same C++ compiler (and linking against one runtime library).
87 CPPUHELPER_DLLPUBLIC
css::uno::Any SAL_CALL
getCaughtException();
93 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */