tdf#130857 qt weld: Support mail merge "Server Auth" dialog
[LibreOffice.git] / include / cppuhelper / exc_hlp.hxx
blobfa3c3d05b331c89ced76584e95196800d9b9c0a2
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 .
21 * This file is part of LibreOffice published API.
24 #ifndef INCLUDED_CPPUHELPER_EXC_HLP_HXX
25 #define INCLUDED_CPPUHELPER_EXC_HLP_HXX
27 #include "com/sun/star/uno/Any.hxx"
28 #include "cppuhelper/cppuhelperdllapi.h"
30 namespace cppu
32 /** This function throws the exception given by rExc. The given value has to
33 be of typeclass EXCEPTION and must be derived from or of
34 type com.sun.star.uno.Exception.
36 @param rExc
37 exception to be thrown.
39 CPPUHELPER_DLLPUBLIC void SAL_CALL throwException(const css::uno::Any& rExc);
41 /** Use this function to get the dynamic type of a caught C++-UNO exception;
42 completes the above function throwing exceptions generically.
44 @code
45 try
47 ...
49 catch (css::uno::RuntimeException &)
51 // you ought not handle RuntimeExceptions:
52 throw;
54 catch (css::uno::Exception &)
56 css::uno::Any caught( ::cppu::getCaughtException() );
57 ...
59 @endcode
61 Restrictions:
62 - use only for caught C++-UNO exceptions (UNOIDL defined)
63 - only as first statement in a catch block!
64 - don't do a C++ rethrow (throw;) after you have called this function
65 - call getCaughtException() just once in your catch block!
66 (function internally uses a C++ rethrow)
68 @return
69 caught UNO exception
71 @attention Caution!
72 This function is limited to the same C++ compiler runtime library.
73 E.g. for MSVC, this means that the catch handler code (the one
74 that calls getCaughtException()) needs to use the very same
75 C++ runtime library, e.g. msvcrt.dll as cppuhelper, e.g.
76 cppuhelper3MSC.dll and the bridge library, e.g. msci_uno.dll.
77 This is the case if all of them are compiled with the same
78 compiler version.
79 Background: The msci_uno.dll gets a rethrown exception out
80 of the internal msvcrt.dll thread local storage (tls).
81 Thus you _must_ not use this function if your code needs to run
82 in newer UDK versions without being recompiled, because those
83 newer UDK (-> OOo versions) potentially use newer C++ runtime
84 libraries which most often become incompatible!
86 But this function ought to be usable for most OOo internal C++-UNO
87 development, because the whole OOo code base is compiled using the
88 same C++ compiler (and linking against one runtime library).
90 CPPUHELPER_DLLPUBLIC css::uno::Any SAL_CALL getCaughtException();
93 #endif
95 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */