summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2019-02-15 10:44:08 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2019-02-19 09:39:48 +0100
commit183debd7e078d2daef38170afc8542a4e625602c (patch)
treeaf1f24b61933b2d9da2cc7bf9e8c95405c1f812c /tools
parent9c1383e4da135db28c422752153e9a77558e8c2f (diff)
pretty up logging of exceptions
Add exceptionToString() and getCaughtExceptionAsString() methods in tools. Use the new methods in DbgUnhandledException() Add special-case case code for most of the exceptions that contain extra fields, so all of the relevant data ends up in the log Change-Id: I376f6549b4d7bd480202f8bff17a454657c75ece Reviewed-on: https://gerrit.libreoffice.org/67857 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'tools')
-rw-r--r--tools/Library_tl.mk1
-rw-r--r--tools/source/debug/debug.cxx356
2 files changed, 319 insertions, 38 deletions
diff --git a/tools/Library_tl.mk b/tools/Library_tl.mk
index acd007cc4761..d6705d0b5925 100644
--- a/tools/Library_tl.mk
+++ b/tools/Library_tl.mk
@@ -37,6 +37,7 @@ $(eval $(call gb_Library_use_libraries,tl,\
comphelper \
i18nlangtag \
cppu \
+ cppuhelper \
sal \
))
diff --git a/tools/source/debug/debug.cxx b/tools/source/debug/debug.cxx
index 9f32eab3267c..efecd0f5027b 100644
--- a/tools/source/debug/debug.cxx
+++ b/tools/source/debug/debug.cxx
@@ -29,7 +29,33 @@
#include <stdio.h>
#include <com/sun/star/configuration/CorruptedConfigurationException.hpp>
+#include <com/sun/star/configuration/backend/BackendSetupException.hpp>
+#include <com/sun/star/configuration/backend/MalformedDataException.hpp>
+#include <com/sun/star/configuration/InvalidBootstrapFileException.hpp>
+#include <com/sun/star/configuration/MissingBootstrapFileException.hpp>
+#include <com/sun/star/deployment/DependencyException.hpp>
+#include <com/sun/star/deployment/DeploymentException.hpp>
+#include <com/sun/star/document/CorruptedFilterConfigurationException.hpp>
+#include <com/sun/star/document/UndoFailedException.hpp>
+#include <com/sun/star/lang/WrappedTargetException.hpp>
+#include <com/sun/star/lang/WrappedTargetRuntimeException.hpp>
+#include <com/sun/star/ldap/LdapGenericException.hpp>
+#include <com/sun/star/script/BasicErrorException.hpp>
+#include <com/sun/star/script/CannotConvertException.hpp>
+#include <com/sun/star/script/provider/ScriptExceptionRaisedException.hpp>
+#include <com/sun/star/script/provider/ScriptFrameworkErrorException.hpp>
+#include <com/sun/star/sdbc/SQLException.hpp>
+#include <com/sun/star/system/SystemShellExecuteException.hpp>
#include <com/sun/star/task/ErrorCodeIOException.hpp>
+#include <com/sun/star/ucb/CommandFailedException.hpp>
+#include <com/sun/star/ucb/ContentCreationException.hpp>
+#include <com/sun/star/ucb/MissingPropertiesException.hpp>
+#include <com/sun/star/ucb/NameClashException.hpp>
+#include <com/sun/star/util/MalformedNumberFormatException.hpp>
+#include <com/sun/star/xml/dom/DOMException.hpp>
+#include <com/sun/star/xml/sax/SAXException.hpp>
+#include <com/sun/star/xml/sax/SAXParseException.hpp>
+#include <comphelper/anytostring.hxx>
#include <tools/debug.hxx>
#include <rtl/string.h>
#include <sal/log.hxx>
@@ -79,55 +105,309 @@ void DbgTestSolarMutex()
#endif
-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)
{
- OString sMessage( "DBG_UNHANDLED_EXCEPTION in " );
- sMessage += currentFunction;
- if (explanatory)
+ auto toOString = [](OUString const & s) {
+ return OUStringToOString( s, osl_getThreadTextEncoding() );
+ };
+ OString sMessage = toOString(caught.getValueTypeName());
+ css::uno::Exception exception;
+ caught >>= exception;
+ if ( !exception.Message.isEmpty() )
+ {
+ sMessage += " message: ";
+ sMessage += toOString(exception.Message);
+ }
+ if ( exception.Context.is() )
+ {
+ const char* pContext = typeid( *exception.Context.get() ).name();
+#if defined __GLIBCXX__
+ // demangle the type name, not necessary under windows, we already get demangled names there
+ int status;
+ pContext = abi::__cxa_demangle( pContext, nullptr, nullptr, &status);
+#endif
+ sMessage += " context: ";
+ sMessage += pContext;
+ }
+ {
+ css::configuration::CorruptedConfigurationException specialized;
+ if ( caught >>= specialized )
{
- sMessage += "\n when: ";
- sMessage += explanatory;
+ sMessage += " details: ";
+ sMessage += toOString(specialized.Details);
}
- sMessage += "\n type: ";
- sMessage += OUStringToOString( caught.getValueTypeName(), osl_getThreadTextEncoding() );
- css::uno::Exception exception;
- caught >>= exception;
- if ( !exception.Message.isEmpty() )
+ }
+ {
+ css::configuration::InvalidBootstrapFileException specialized;
+ if ( caught >>= specialized )
{
- sMessage += "\n message: ";
- sMessage += OUStringToOString( exception.Message, osl_getThreadTextEncoding() );
+ sMessage += " BootstrapFileURL: ";
+ sMessage += toOString(specialized.BootstrapFileURL);
}
- if ( exception.Context.is() )
+ }
+ {
+ css::configuration::MissingBootstrapFileException specialized;
+ if ( caught >>= specialized )
{
- const char* pContext = typeid( *exception.Context.get() ).name();
-#if defined __GLIBCXX__
- // demangle the type name, not necessary under windows, we already get demangled names there
- int status;
- pContext = abi::__cxa_demangle( pContext, nullptr, nullptr, &status);
-#endif
- sMessage += "\n context: ";
- sMessage += pContext;
+ sMessage += " BootstrapFileURL: ";
+ sMessage += toOString(specialized.BootstrapFileURL);
}
+ }
+ {
+ css::configuration::backend::MalformedDataException specialized;
+ if ( caught >>= specialized )
{
- css::configuration::CorruptedConfigurationException
- specialized;
- if ( caught >>= specialized )
- {
- sMessage += "\n details: ";
- sMessage += OUStringToOString(
- specialized.Details, osl_getThreadTextEncoding() );
- }
+ sMessage += "\n wrapped: ";
+ sMessage += exceptionToString(specialized.ErrorDetails);
}
+ }
+ {
+ css::configuration::backend::BackendSetupException specialized;
+ if ( caught >>= specialized )
{
- css::task::ErrorCodeIOException specialized;
- if ( caught >>= specialized )
- {
- sMessage += "\n details: ";
- sMessage += OString::number( specialized.ErrCode );
- }
+ sMessage += "\n wrapped: ";
+ sMessage += exceptionToString(specialized.BackendException);
+ }
+ }
+ {
+ css::deployment::DependencyException specialized;
+ if ( caught >>= specialized )
+ {
+ sMessage += " UnsatisfiedDependencies: ";
+ sMessage += toOString(comphelper::anyToString(css::uno::Any(specialized.UnsatisfiedDependencies)));
+ }
+ }
+ {
+ css::deployment::DeploymentException specialized;
+ if ( caught >>= specialized )
+ {
+ sMessage += "\n wrapped: ";
+ sMessage += exceptionToString(specialized.Cause);
+ }
+ }
+ {
+ css::document::CorruptedFilterConfigurationException specialized;
+ if ( caught >>= specialized )
+ {
+ sMessage += " Details: ";
+ sMessage += toOString(specialized.Details);
+ }
+ }
+ {
+ css::document::UndoFailedException specialized;
+ if ( caught >>= specialized )
+ {
+ sMessage += " Reason: ";
+ sMessage += toOString(comphelper::anyToString(specialized.Reason));
+ }
+ }
+ {
+ css::lang::IllegalArgumentException specialized;
+ if ( caught >>= specialized )
+ {
+ sMessage += " ArgumentPosition: ";
+ sMessage += OString::number(specialized.ArgumentPosition);
+ }
+ }
+ {
+ css::lang::WrappedTargetException specialized;
+ if ( caught >>= specialized )
+ {
+ sMessage += "\n wrapped: ";
+ sMessage += exceptionToString(specialized.TargetException);
+ }
+ }
+ {
+ css::lang::WrappedTargetRuntimeException specialized;
+ if ( caught >>= specialized )
+ {
+ sMessage += "\n wrapped: ";
+ sMessage += exceptionToString(specialized.TargetException);
+ }
+ }
+ {
+ css::ldap::LdapGenericException specialized;
+ if ( caught >>= specialized )
+ {
+ sMessage += " ErrorCode: ";
+ sMessage += OString::number(specialized.ErrorCode);
+ }
+ }
+ {
+ css::script::BasicErrorException specialized;
+ if ( caught >>= specialized )
+ {
+ sMessage += " ErrorCode: ";
+ sMessage += OString::number(specialized.ErrorCode);
+ sMessage += " ErrorMessageArgument: ";
+ sMessage += toOString(specialized.ErrorMessageArgument);
+ }
+ }
+ {
+ css::script::CannotConvertException specialized;
+ if ( caught >>= specialized )
+ {
+ sMessage += " DestinationTypeClass: ";
+ sMessage += toOString(comphelper::anyToString(css::uno::Any(specialized.DestinationTypeClass)));
+ sMessage += " Reason: ";
+ sMessage += OString::number(specialized.Reason);
+ sMessage += " ArgumentIndex: ";
+ sMessage += OString::number(specialized.ArgumentIndex);
+ }
+ }
+ {
+ css::script::provider::ScriptErrorRaisedException specialized;
+ if ( caught >>= specialized )
+ {
+ sMessage += " scriptName: ";
+ sMessage += toOString(specialized.scriptName);
+ sMessage += " language: ";
+ sMessage += toOString(specialized.language);
+ sMessage += " lineNum: ";
+ sMessage += OString::number(specialized.lineNum);
+ }
+ }
+ {
+ css::script::provider::ScriptExceptionRaisedException specialized;
+ if ( caught >>= specialized )
+ {
+ sMessage += " exceptionType: ";
+ sMessage += toOString(specialized.exceptionType);
+ }
+ }
+ {
+ css::script::provider::ScriptFrameworkErrorException specialized;
+ if ( caught >>= specialized )
+ {
+ sMessage += " scriptName: ";
+ sMessage += toOString(specialized.scriptName);
+ sMessage += " language: ";
+ sMessage += toOString(specialized.language);
+ sMessage += " errorType: ";
+ sMessage += OString::number(specialized.errorType);
+ }
+ }
+ {
+ css::sdbc::SQLException specialized;
+ if ( caught >>= specialized )
+ {
+ sMessage += " SQLState: ";
+ sMessage += toOString(specialized.SQLState);
+ sMessage += " ErrorCode: ";
+ sMessage += OString::number(specialized.ErrorCode);
+ sMessage += "\n wrapped: ";
+ sMessage += exceptionToString(specialized.NextException);
+ }
+ }
+ {
+ css::system::SystemShellExecuteException specialized;
+ if ( caught >>= specialized )
+ {
+ sMessage += " PosixError: ";
+ sMessage += OString::number(specialized.PosixError);
+ }
+ }
+ {
+ css::task::ErrorCodeIOException specialized;
+ if ( caught >>= specialized )
+ {
+ sMessage += " errcode: ";
+ sMessage += OString::number( specialized.ErrCode );
+ }
+ }
+ {
+ css::ucb::CommandFailedException specialized;
+ if ( caught >>= specialized )
+ {
+ sMessage += "\n Reason: ";
+ sMessage += exceptionToString( specialized.Reason );
+ }
+ }
+ {
+ css::ucb::ContentCreationException specialized;
+ if ( caught >>= specialized )
+ {
+ sMessage += " eError: ";
+ sMessage += toOString(comphelper::anyToString( css::uno::Any(specialized.eError) ));
+ }
+ }
+ {
+ css::ucb::MissingPropertiesException specialized;
+ if ( caught >>= specialized )
+ {
+ sMessage += " Properties: ";
+ sMessage += toOString(comphelper::anyToString( css::uno::Any(specialized.Properties) ));
+ }
+ }
+ {
+ css::ucb::NameClashException specialized;
+ if ( caught >>= specialized )
+ {
+ sMessage += " Name: ";
+ sMessage += toOString( specialized.Name );
+ }
+ }
+ {
+ css::util::MalformedNumberFormatException specialized;
+ if ( caught >>= specialized )
+ {
+ sMessage += " CheckPos: ";
+ sMessage += OString::number( specialized.CheckPos );
+ }
+ }
+ {
+ css::xml::dom::DOMException specialized;
+ if ( caught >>= specialized )
+ {
+ sMessage += " Code: ";
+ sMessage += toOString(comphelper::anyToString( css::uno::Any(specialized.Code) ));
+ }
+ }
+ {
+ css::xml::dom::DOMException specialized;
+ if ( caught >>= specialized )
+ {
+ sMessage += " Code: ";
+ sMessage += toOString(comphelper::anyToString( css::uno::Any(specialized.Code) ));
+ }
+ }
+ {
+ css::xml::sax::SAXException specialized;
+ if ( caught >>= specialized )
+ {
+ sMessage += "\n wrapped: ";
+ sMessage += exceptionToString( specialized.WrappedException );
+ }
+ }
+ {
+ css::xml::sax::SAXParseException specialized;
+ if ( caught >>= specialized )
+ {
+ sMessage += " PublicId: ";
+ sMessage += toOString( specialized.PublicId );
+ sMessage += " SystemId: ";
+ sMessage += toOString( specialized.SystemId );
+ sMessage += " LineNumber: ";
+ sMessage += OString::number( specialized.LineNumber );
+ sMessage += " ColumnNumber: ";
+ sMessage += OString::number( specialized.ColumnNumber );
+ }
+ }
+ return sMessage;
+}
+
+void DbgUnhandledException(const css::uno::Any & caught, const char* currentFunction, const char* fileAndLineNo,
+ const char* area, const char* explanatory)
+{
+ OString sMessage( "DBG_UNHANDLED_EXCEPTION in " );
+ sMessage += currentFunction;
+ if (explanatory)
+ {
+ sMessage += "\n when: ";
+ sMessage += explanatory;
}
- sMessage += "\n";
+ sMessage += " exception: ";
+ sMessage += exceptionToString(caught);
if (area == nullptr)
area = "legacy.osl";