diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2011-10-07 21:09:41 +0200 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2011-10-07 22:06:28 +0200 |
commit | 29e11dd13efc2d1325b0f424788484bc8ecf0ce1 (patch) | |
tree | 9f3a5d91b615dbafd428dfc0b210ccb07e738517 | |
parent | 78b1cc1a08d712212152a1e57400c8b07654e471 (diff) |
Improved exception reporting.
-rw-r--r-- | framework/source/accelerators/presethandler.cxx | 50 | ||||
-rw-r--r-- | tools/inc/tools/diagnose_ex.h | 15 |
2 files changed, 45 insertions, 20 deletions
diff --git a/framework/source/accelerators/presethandler.cxx b/framework/source/accelerators/presethandler.cxx index bcd4788790d0..45c9c4ec8847 100644 --- a/framework/source/accelerators/presethandler.cxx +++ b/framework/source/accelerators/presethandler.cxx @@ -59,7 +59,7 @@ //_______________________________________________ // other includes #include <vcl/svapp.hxx> - +#include <cppuhelper/exc_hlp.hxx> #include <rtl/ustrbuf.hxx> //_______________________________________________ @@ -209,7 +209,8 @@ void PresetHandler::forgetCachedStorages() // <- SAFE ---------------------------------- } -//----------------------------------------------- +namespace { + ::rtl::OUString lcl_getLocalizedMessage(::sal_Int32 nID) { ::rtl::OUString sMessage(RTL_CONSTASCII_USTRINGPARAM("Unknown error.")); @@ -218,6 +219,7 @@ void PresetHandler::forgetCachedStorages() { case ID_CORRUPT_UICONFIG_SHARE : sMessage = ::rtl::OUString( String( FwkResId( STR_CORRUPT_UICFG_SHARE ))); + break; case ID_CORRUPT_UICONFIG_USER : @@ -232,7 +234,22 @@ void PresetHandler::forgetCachedStorages() return sMessage; } -//----------------------------------------------- +void lcl_throwCorruptedUIConfigurationException( + css::uno::Any const & exception, sal_Int32 id) +{ + css::uno::Exception e; + bool ok = (exception >>= e); + OSL_ASSERT(ok); (void) ok; // avoid warnings + throw css::configuration::CorruptedUIConfigurationException( + lcl_getLocalizedMessage(id), + css::uno::Reference< css::uno::XInterface >(), + (exception.getValueTypeName() + + rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(": \"")) + e.Message + + rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("\"")))); +} + +} + css::uno::Reference< css::embed::XStorage > PresetHandler::getOrCreateRootStorageShare() { css::uno::Reference< css::embed::XStorage > xRoot = m_aSharedStorages->m_lStoragesShare.getRootStorage(); @@ -280,12 +297,11 @@ css::uno::Reference< css::embed::XStorage > PresetHandler::getOrCreateRootStorag { xStorage = css::uno::Reference< css::embed::XStorage >(xStorageFactory->createInstanceWithArguments(lArgs), css::uno::UNO_QUERY_THROW); } - catch(const css::uno::Exception& ex) + catch(const css::uno::Exception&) { - throw css::configuration::CorruptedUIConfigurationException( - lcl_getLocalizedMessage(ID_CORRUPT_UICONFIG_SHARE), - css::uno::Reference< css::uno::XInterface >(), - ex.Message); + css::uno::Any ex(cppu::getCaughtException()); + lcl_throwCorruptedUIConfigurationException( + ex, ID_CORRUPT_UICONFIG_SHARE); } m_aSharedStorages->m_lStoragesShare.setRootStorage(xStorage); @@ -331,12 +347,11 @@ css::uno::Reference< css::embed::XStorage > PresetHandler::getOrCreateRootStorag { xStorage = css::uno::Reference< css::embed::XStorage >(xStorageFactory->createInstanceWithArguments(lArgs), css::uno::UNO_QUERY_THROW); } - catch(const css::uno::Exception& ex) + catch(const css::uno::Exception&) { - throw css::configuration::CorruptedUIConfigurationException( - lcl_getLocalizedMessage(ID_CORRUPT_UICONFIG_USER), - css::uno::Reference< css::uno::XInterface >(), - ex.Message); + css::uno::Any ex(cppu::getCaughtException()); + lcl_throwCorruptedUIConfigurationException( + ex, ID_CORRUPT_UICONFIG_USER); } m_aSharedStorages->m_lStoragesUser.setRootStorage(xStorage); @@ -585,12 +600,11 @@ void PresetHandler::connectToResource( PresetHandler::EConfigType // <- SAFE ---------------------------------- } - catch(const css::uno::Exception& ex) + catch(const css::uno::Exception&) { - throw css::configuration::CorruptedUIConfigurationException( - lcl_getLocalizedMessage(ID_CORRUPT_UICONFIG_GENERAL), - css::uno::Reference< css::uno::XInterface >(), - ex.Message); + css::uno::Any ex(cppu::getCaughtException()); + lcl_throwCorruptedUIConfigurationException( + ex, ID_CORRUPT_UICONFIG_GENERAL); } } diff --git a/tools/inc/tools/diagnose_ex.h b/tools/inc/tools/diagnose_ex.h index 5dd8951fd61e..ce1b5a3d8db2 100644 --- a/tools/inc/tools/diagnose_ex.h +++ b/tools/inc/tools/diagnose_ex.h @@ -43,6 +43,7 @@ #if OSL_DEBUG_LEVEL > 0 + #include <com/sun/star/configuration/CorruptedConfigurationException.hpp> #include <cppuhelper/exc_hlp.hxx> #include <osl/diagnose.h> #include <osl/thread.h> @@ -60,13 +61,13 @@ sMessage += "\nin function:"; \ sMessage += BOOST_CURRENT_FUNCTION; \ sMessage += "\ntype: "; \ - sMessage += ::rtl::OString( caught.getValueTypeName().getStr(), caught.getValueTypeName().getLength(), osl_getThreadTextEncoding() ); \ + sMessage += ::rtl::OUStringToOString( caught.getValueTypeName(), osl_getThreadTextEncoding() ); \ ::com::sun::star::uno::Exception exception; \ caught >>= exception; \ if ( exception.Message.getLength() ) \ { \ sMessage += "\nmessage: "; \ - sMessage += ::rtl::OString( exception.Message.getStr(), exception.Message.getLength(), osl_getThreadTextEncoding() ); \ + sMessage += ::rtl::OUStringToOString( exception.Message, osl_getThreadTextEncoding() ); \ } \ if ( exception.Context.is() ) \ { \ @@ -74,6 +75,16 @@ sMessage += "\ncontext: "; \ sMessage += pContext; \ } \ + { \ + ::com::sun::star::configuration::CorruptedConfigurationException \ + specialized; \ + if ( caught >>= specialized ) \ + { \ + sMessage += "\ndetails: "; \ + sMessage += ::rtl::OUStringToOString( \ + specialized.Details, osl_getThreadTextEncoding() ); \ + } \ + } \ sMessage += "\n"; \ OSL_ENSURE( false, sMessage.getStr() ) |