20#include <com/sun/star/configuration/CorruptedConfigurationException.hpp>
21#include <com/sun/star/configuration/backend/BackendSetupException.hpp>
22#include <com/sun/star/configuration/backend/MalformedDataException.hpp>
23#include <com/sun/star/configuration/InvalidBootstrapFileException.hpp>
24#include <com/sun/star/configuration/MissingBootstrapFileException.hpp>
25#include <com/sun/star/deployment/DependencyException.hpp>
26#include <com/sun/star/deployment/DeploymentException.hpp>
27#include <com/sun/star/document/CorruptedFilterConfigurationException.hpp>
28#include <com/sun/star/document/UndoFailedException.hpp>
29#include <com/sun/star/lang/IllegalArgumentException.hpp>
30#include <com/sun/star/lang/WrappedTargetException.hpp>
31#include <com/sun/star/lang/WrappedTargetRuntimeException.hpp>
32#include <com/sun/star/ldap/LdapGenericException.hpp>
33#include <com/sun/star/script/BasicErrorException.hpp>
34#include <com/sun/star/script/CannotConvertException.hpp>
35#include <com/sun/star/script/provider/ScriptExceptionRaisedException.hpp>
36#include <com/sun/star/script/provider/ScriptFrameworkErrorException.hpp>
37#include <com/sun/star/sdbc/SQLException.hpp>
38#include <com/sun/star/system/SystemShellExecuteException.hpp>
39#include <com/sun/star/task/ErrorCodeIOException.hpp>
40#include <com/sun/star/ucb/CommandFailedException.hpp>
41#include <com/sun/star/ucb/ContentCreationException.hpp>
42#include <com/sun/star/ucb/MissingPropertiesException.hpp>
43#include <com/sun/star/ucb/NameClashException.hpp>
44#include <com/sun/star/ucb/InteractiveIOException.hpp>
45#include <com/sun/star/util/MalformedNumberFormatException.hpp>
46#include <com/sun/star/xml/dom/DOMException.hpp>
47#include <com/sun/star/xml/sax/SAXException.hpp>
48#include <com/sun/star/xml/sax/SAXParseException.hpp>
51#include <osl/thread.h>
52#include <rtl/strbuf.hxx>
56#if defined __GLIBCXX__
62 auto toOString = [](OUString
const & s) {
65 sMessage.append(toOString(caught.getValueTypeName()));
66 css::uno::Exception exception;
68 if ( !exception.Message.isEmpty() )
71 sMessage.append(toOString(exception.Message));
74 if ( exception.Context.is() )
76 const char* pContext =
typeid( *exception.Context ).
name();
77#if defined __GLIBCXX__
80 pContext = abi::__cxa_demangle( pContext,
nullptr,
nullptr, &status);
84#if defined __GLIBCXX__
85 std::free(
const_cast<char *
>(pContext));
89 css::configuration::CorruptedConfigurationException specialized;
90 if ( caught >>= specialized )
93 sMessage.append(toOString(specialized.Details));
97 css::configuration::InvalidBootstrapFileException specialized;
98 if ( caught >>= specialized )
100 sMessage.append(
" BootstrapFileURL: ");
101 sMessage.append(toOString(specialized.BootstrapFileURL));
105 css::configuration::MissingBootstrapFileException specialized;
106 if ( caught >>= specialized )
108 sMessage.append(
" BootstrapFileURL: ");
109 sMessage.append(toOString(specialized.BootstrapFileURL));
113 css::configuration::backend::MalformedDataException specialized;
114 if ( caught >>= specialized )
121 css::configuration::backend::BackendSetupException specialized;
122 if ( caught >>= specialized )
129 css::deployment::DependencyException specialized;
130 if ( caught >>= specialized )
132 sMessage.append(
" UnsatisfiedDependencies: ");
137 css::deployment::DeploymentException specialized;
138 if ( caught >>= specialized )
145 css::document::CorruptedFilterConfigurationException specialized;
146 if ( caught >>= specialized )
149 sMessage.append(toOString(specialized.Details));
153 css::document::UndoFailedException specialized;
154 if ( caught >>= specialized )
161 css::lang::IllegalArgumentException specialized;
162 if ( caught >>= specialized )
164 sMessage.append(
" ArgumentPosition: ");
165 sMessage.append(
static_cast<sal_Int32
>(specialized.ArgumentPosition));
169 css::lang::WrappedTargetException specialized;
170 if ( caught >>= specialized )
177 css::lang::WrappedTargetRuntimeException specialized;
178 if ( caught >>= specialized )
185 css::ldap::LdapGenericException specialized;
186 if ( caught >>= specialized )
189 sMessage.append(specialized.ErrorCode);
193 css::script::BasicErrorException specialized;
194 if ( caught >>= specialized )
197 sMessage.append(specialized.ErrorCode);
198 sMessage.append(
" ErrorMessageArgument: ");
199 sMessage.append(toOString(specialized.ErrorMessageArgument));
203 css::script::CannotConvertException specialized;
204 if ( caught >>= specialized )
206 sMessage.append(
" DestinationTypeClass: ");
209 sMessage.append(specialized.Reason);
210 sMessage.append(
" ArgumentIndex: ");
211 sMessage.append(specialized.ArgumentIndex);
215 css::script::provider::ScriptErrorRaisedException specialized;
216 if ( caught >>= specialized )
219 sMessage.append(toOString(specialized.scriptName));
221 sMessage.append(toOString(specialized.language));
223 sMessage.append(specialized.lineNum);
227 css::script::provider::ScriptExceptionRaisedException specialized;
228 if ( caught >>= specialized )
230 sMessage.append(
" exceptionType: ");
231 sMessage.append(toOString(specialized.exceptionType));
235 css::script::provider::ScriptFrameworkErrorException specialized;
236 if ( caught >>= specialized )
239 sMessage.append(toOString(specialized.scriptName));
241 sMessage.append(toOString(specialized.language));
243 sMessage.append(specialized.errorType);
247 css::sdbc::SQLException specialized;
248 if ( caught >>= specialized )
251 sMessage.append(toOString(specialized.SQLState));
253 sMessage.append(specialized.ErrorCode);
259 css::system::SystemShellExecuteException specialized;
260 if ( caught >>= specialized )
263 sMessage.append(specialized.PosixError);
267 css::task::ErrorCodeIOException specialized;
268 if ( caught >>= specialized )
271 sMessage.append( specialized.ErrCode );
275 css::ucb::CommandFailedException specialized;
276 if ( caught >>= specialized )
283 css::ucb::ContentCreationException specialized;
284 if ( caught >>= specialized )
291 css::ucb::MissingPropertiesException specialized;
292 if ( caught >>= specialized )
299 css::ucb::NameClashException specialized;
300 if ( caught >>= specialized )
303 sMessage.append(toOString( specialized.Name ));
307 css::util::MalformedNumberFormatException specialized;
308 if ( caught >>= specialized )
311 sMessage.append( specialized.CheckPos );
315 css::xml::dom::DOMException specialized;
316 if ( caught >>= specialized )
323 css::xml::dom::DOMException specialized;
324 if ( caught >>= specialized )
331 css::xml::sax::SAXException specialized;
332 if ( caught >>= specialized )
339 css::xml::sax::SAXParseException specialized;
340 if ( caught >>= specialized )
343 sMessage.append(toOString( specialized.PublicId ));
345 sMessage.append(toOString( specialized.SystemId ));
347 sMessage.append( specialized.LineNumber );
349 sMessage.append( specialized.ColumnNumber );
353 css::ucb::InteractiveIOException specialized;
354 if ( caught >>= specialized )
357 sMessage.append(
static_cast<sal_Int32
>(specialized.Code) );
366 return sMessage.makeStringAndClear();
370 const char* area,
const char* explanatory)
373 sMessage.append( OString::Concat(
"DBG_UNHANDLED_EXCEPTION in ") + currentFunction);
376 sMessage.append(OString::Concat(
"\n when: ") + explanatory);
384 SAL_DETAIL_LOG_FORMAT(
385 SAL_DETAIL_ENABLE_LOG_WARN, SAL_DETAIL_LOG_LEVEL_WARN,
386 area, fileAndLineNo,
"%s",
sMessage.getStr());
void DbgUnhandledException(const css::uno::Any &caught, const char *currentFunction, const char *fileAndLineNo, const char *area, const char *explanatory)
OString exceptionToString(const css::uno::Any &caught)
Convert a caught exception to a string suitable for logging.
static void exceptionToStringImpl(OStringBuffer &sMessage, const css::uno::Any &caught)
OUString anyToString(uno::Any const &value)
OString OUStringToOString(std::u16string_view str, ConnectionSettings const *settings)