diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2019-10-01 18:24:17 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2019-10-02 08:01:38 +0200 |
commit | 9e5b43ff37683b7b67be96c2953e851498a310c9 (patch) | |
tree | 2ee9d3e1d60b5feaf800adacdd397487f255af89 /tools | |
parent | 32617df2f59b05ca5942fd18b3440ec834982565 (diff) |
loplugin:stringadd in tools..unotools
Change-Id: I441a5ccef6adc8be8029178e304ff3044e812e2a
Reviewed-on: https://gerrit.libreoffice.org/79986
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/source/debug/debug.cxx | 205 |
1 files changed, 106 insertions, 99 deletions
diff --git a/tools/source/debug/debug.cxx b/tools/source/debug/debug.cxx index 9b9419599b7d..22c3b08698bd 100644 --- a/tools/source/debug/debug.cxx +++ b/tools/source/debug/debug.cxx @@ -50,6 +50,7 @@ #include <tools/debug.hxx> #include <sal/log.hxx> #include <osl/thread.h> +#include <rtl/strbuf.hxx> #include <cstdlib> #include <typeinfo> @@ -94,18 +95,18 @@ void DbgTestSolarMutex() #endif -OString exceptionToString(const css::uno::Any & caught) +static void exceptionToStringImpl(OStringBuffer& sMessage, const css::uno::Any & caught) { auto toOString = [](OUString const & s) { return OUStringToOString( s, osl_getThreadTextEncoding() ); }; - OString sMessage = toOString(caught.getValueTypeName()); + sMessage.append(toOString(caught.getValueTypeName())); css::uno::Exception exception; caught >>= exception; if ( !exception.Message.isEmpty() ) { - sMessage += " message: "; - sMessage += toOString(exception.Message); + sMessage.append(" message: "); + sMessage.append(toOString(exception.Message)); } if ( exception.Context.is() ) { @@ -115,8 +116,8 @@ OString exceptionToString(const css::uno::Any & caught) int status; pContext = abi::__cxa_demangle( pContext, nullptr, nullptr, &status); #endif - sMessage += " context: "; - sMessage += pContext; + sMessage.append(" context: "); + sMessage.append(pContext); #if defined __GLIBCXX__ std::free(const_cast<char *>(pContext)); #endif @@ -125,289 +126,295 @@ OString exceptionToString(const css::uno::Any & caught) css::configuration::CorruptedConfigurationException specialized; if ( caught >>= specialized ) { - sMessage += " details: "; - sMessage += toOString(specialized.Details); + sMessage.append(" details: "); + sMessage.append(toOString(specialized.Details)); } } { css::configuration::InvalidBootstrapFileException specialized; if ( caught >>= specialized ) { - sMessage += " BootstrapFileURL: "; - sMessage += toOString(specialized.BootstrapFileURL); + sMessage.append(" BootstrapFileURL: "); + sMessage.append(toOString(specialized.BootstrapFileURL)); } } { css::configuration::MissingBootstrapFileException specialized; if ( caught >>= specialized ) { - sMessage += " BootstrapFileURL: "; - sMessage += toOString(specialized.BootstrapFileURL); + sMessage.append(" BootstrapFileURL: "); + sMessage.append(toOString(specialized.BootstrapFileURL)); } } { css::configuration::backend::MalformedDataException specialized; if ( caught >>= specialized ) { - sMessage += "\n wrapped: "; - sMessage += exceptionToString(specialized.ErrorDetails); + sMessage.append("\n wrapped: "); + sMessage.append(exceptionToString(specialized.ErrorDetails)); } } { css::configuration::backend::BackendSetupException specialized; if ( caught >>= specialized ) { - sMessage += "\n wrapped: "; - sMessage += exceptionToString(specialized.BackendException); + sMessage.append("\n wrapped: "); + sMessage.append(exceptionToString(specialized.BackendException)); } } { css::deployment::DependencyException specialized; if ( caught >>= specialized ) { - sMessage += " UnsatisfiedDependencies: "; - sMessage += toOString(comphelper::anyToString(css::uno::Any(specialized.UnsatisfiedDependencies))); + sMessage.append(" UnsatisfiedDependencies: "); + sMessage.append(toOString(comphelper::anyToString(css::uno::Any(specialized.UnsatisfiedDependencies)))); } } { css::deployment::DeploymentException specialized; if ( caught >>= specialized ) { - sMessage += "\n wrapped: "; - sMessage += exceptionToString(specialized.Cause); + sMessage.append("\n wrapped: "); + sMessage.append(exceptionToString(specialized.Cause)); } } { css::document::CorruptedFilterConfigurationException specialized; if ( caught >>= specialized ) { - sMessage += " Details: "; - sMessage += toOString(specialized.Details); + sMessage.append(" Details: "); + sMessage.append(toOString(specialized.Details)); } } { css::document::UndoFailedException specialized; if ( caught >>= specialized ) { - sMessage += " Reason: "; - sMessage += toOString(comphelper::anyToString(specialized.Reason)); + sMessage.append(" Reason: "); + sMessage.append(toOString(comphelper::anyToString(specialized.Reason))); } } { css::lang::IllegalArgumentException specialized; if ( caught >>= specialized ) { - sMessage += " ArgumentPosition: "; - sMessage += OString::number(specialized.ArgumentPosition); + sMessage.append(" ArgumentPosition: "); + sMessage.append(OString::number(specialized.ArgumentPosition)); } } { css::lang::WrappedTargetException specialized; if ( caught >>= specialized ) { - sMessage += "\n wrapped: "; - sMessage += exceptionToString(specialized.TargetException); + sMessage.append("\n wrapped: "); + sMessage.append(exceptionToString(specialized.TargetException)); } } { css::lang::WrappedTargetRuntimeException specialized; if ( caught >>= specialized ) { - sMessage += "\n wrapped: "; - sMessage += exceptionToString(specialized.TargetException); + sMessage.append("\n wrapped: "); + sMessage.append(exceptionToString(specialized.TargetException)); } } { css::ldap::LdapGenericException specialized; if ( caught >>= specialized ) { - sMessage += " ErrorCode: "; - sMessage += OString::number(specialized.ErrorCode); + sMessage.append(" ErrorCode: "); + sMessage.append(OString::number(specialized.ErrorCode)); } } { css::script::BasicErrorException specialized; if ( caught >>= specialized ) { - sMessage += " ErrorCode: "; - sMessage += OString::number(specialized.ErrorCode); - sMessage += " ErrorMessageArgument: "; - sMessage += toOString(specialized.ErrorMessageArgument); + sMessage.append(" ErrorCode: "); + sMessage.append(OString::number(specialized.ErrorCode)); + sMessage.append(" ErrorMessageArgument: "); + sMessage.append(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); + sMessage.append(" DestinationTypeClass: "); + sMessage.append(toOString(comphelper::anyToString(css::uno::Any(specialized.DestinationTypeClass)))); + sMessage.append(" Reason: "); + sMessage.append(OString::number(specialized.Reason)); + sMessage.append(" ArgumentIndex: "); + sMessage.append(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); + sMessage.append(" scriptName: "); + sMessage.append(toOString(specialized.scriptName)); + sMessage.append(" language: "); + sMessage.append(toOString(specialized.language)); + sMessage.append(" lineNum: "); + sMessage.append(OString::number(specialized.lineNum)); } } { css::script::provider::ScriptExceptionRaisedException specialized; if ( caught >>= specialized ) { - sMessage += " exceptionType: "; - sMessage += toOString(specialized.exceptionType); + sMessage.append(" exceptionType: "); + sMessage.append(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); + sMessage.append(" scriptName: "); + sMessage.append(toOString(specialized.scriptName)); + sMessage.append(" language: "); + sMessage.append(toOString(specialized.language)); + sMessage.append(" errorType: "); + sMessage.append(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); + sMessage.append(" SQLState: "); + sMessage.append(toOString(specialized.SQLState)); + sMessage.append(" ErrorCode: "); + sMessage.append(OString::number(specialized.ErrorCode)); + sMessage.append("\n wrapped: "); + sMessage.append(exceptionToString(specialized.NextException)); } } { css::system::SystemShellExecuteException specialized; if ( caught >>= specialized ) { - sMessage += " PosixError: "; - sMessage += OString::number(specialized.PosixError); + sMessage.append(" PosixError: "); + sMessage.append(OString::number(specialized.PosixError)); } } { css::task::ErrorCodeIOException specialized; if ( caught >>= specialized ) { - sMessage += " errcode: "; - sMessage += OString::number( specialized.ErrCode ); + sMessage.append(" errcode: "); + sMessage.append(OString::number( specialized.ErrCode )); } } { css::ucb::CommandFailedException specialized; if ( caught >>= specialized ) { - sMessage += "\n Reason: "; - sMessage += exceptionToString( specialized.Reason ); + sMessage.append("\n Reason: "); + sMessage.append(exceptionToString( specialized.Reason )); } } { css::ucb::ContentCreationException specialized; if ( caught >>= specialized ) { - sMessage += " eError: "; - sMessage += toOString(comphelper::anyToString( css::uno::Any(specialized.eError) )); + sMessage.append(" eError: "); + sMessage.append(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) )); + sMessage.append(" Properties: "); + sMessage.append(toOString(comphelper::anyToString( css::uno::Any(specialized.Properties) ))); } } { css::ucb::NameClashException specialized; if ( caught >>= specialized ) { - sMessage += " Name: "; - sMessage += toOString( specialized.Name ); + sMessage.append(" Name: "); + sMessage.append(toOString( specialized.Name )); } } { css::util::MalformedNumberFormatException specialized; if ( caught >>= specialized ) { - sMessage += " CheckPos: "; - sMessage += OString::number( specialized.CheckPos ); + sMessage.append(" CheckPos: "); + sMessage.append(OString::number( specialized.CheckPos )); } } { css::xml::dom::DOMException specialized; if ( caught >>= specialized ) { - sMessage += " Code: "; - sMessage += toOString(comphelper::anyToString( css::uno::Any(specialized.Code) )); + sMessage.append(" Code: "); + sMessage.append(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) )); + sMessage.append(" Code: "); + sMessage.append(toOString(comphelper::anyToString( css::uno::Any(specialized.Code) ))); } } { css::xml::sax::SAXException specialized; if ( caught >>= specialized ) { - sMessage += "\n wrapped: "; - sMessage += exceptionToString( specialized.WrappedException ); + sMessage.append("\n wrapped: "); + sMessage.append(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 ); + sMessage.append(" PublicId: "); + sMessage.append(toOString( specialized.PublicId )); + sMessage.append(" SystemId: "); + sMessage.append(toOString( specialized.SystemId )); + sMessage.append(" LineNumber: "); + sMessage.append(OString::number( specialized.LineNumber )); + sMessage.append(" ColumnNumber: "); + sMessage.append(OString::number( specialized.ColumnNumber )); } } { css::ucb::InteractiveIOException specialized; if ( caught >>= specialized ) { - sMessage += " Code: "; - sMessage += OString::number( static_cast<sal_Int32>(specialized.Code) ); + sMessage.append(" Code: "); + sMessage.append(OString::number( static_cast<sal_Int32>(specialized.Code) )); } } - return sMessage; +} + +OString exceptionToString(const css::uno::Any & caught) +{ + OStringBuffer sMessage; + exceptionToStringImpl(sMessage, caught); + return sMessage.makeStringAndClear(); } 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; + OStringBuffer sMessage( "DBG_UNHANDLED_EXCEPTION in " ); + sMessage.append(currentFunction); if (explanatory) { - sMessage += "\n when: "; - sMessage += explanatory; + sMessage.append("\n when: "); + sMessage.append(explanatory); } - sMessage += " exception: "; - sMessage += exceptionToString(caught); + sMessage.append(" exception: "); + exceptionToStringImpl(sMessage, caught); if (area == nullptr) area = "legacy.osl"; |