Improve some error reporting

Change-Id: Ibfdb0eeebec785438d46a0e8e6e9f4c847bfb807
This commit is contained in:
Stephan Bergmann
2016-11-02 10:33:49 +01:00
parent 1851e87627
commit d2615f96ac
2 changed files with 15 additions and 23 deletions

View File

@@ -812,13 +812,19 @@ void cppuhelper::ServiceManager::loadImplementation(
if (ctor != nullptr) { if (ctor != nullptr) {
assert(!implementation->info->environment.isEmpty()); assert(!implementation->info->environment.isEmpty());
css::uno::Environment curEnv(css::uno::Environment::getCurrent()); css::uno::Environment curEnv(css::uno::Environment::getCurrent());
if (!curEnv.is()) {
throw css::uno::DeploymentException(
"cannot get current environment",
css::uno::Reference<css::uno::XInterface>());
}
css::uno::Environment env( css::uno::Environment env(
cppuhelper::detail::getEnvironment( cppuhelper::detail::getEnvironment(
implementation->info->environment, implementation->info->environment,
implementation->info->name)); implementation->info->name));
if (!(curEnv.is() && env.is())) { if (!env.is()) {
throw css::uno::DeploymentException( throw css::uno::DeploymentException(
"cannot get environments", ("cannot get environment "
+ implementation->info->environment),
css::uno::Reference<css::uno::XInterface>()); css::uno::Reference<css::uno::XInterface>());
} }
if (curEnv.get() != env.get()) { if (curEnv.get() != env.get()) {

View File

@@ -1205,6 +1205,8 @@ void SvxScriptOrgDialog::RestorePreviousSelection()
m_pScriptsBox->SetCurEntry( pEntry ); m_pScriptsBox->SetCurEntry( pEntry );
} }
namespace {
OUString ReplaceString( OUString ReplaceString(
const OUString& source, const OUString& source,
const OUString& token, const OUString& token,
@@ -1368,21 +1370,6 @@ OUString GetErrorMessage(
unformatted, language, script, OUString(), OUString(), message ); unformatted, language, script, OUString(), OUString(), message );
} }
OUString GetErrorMessage( const RuntimeException& re )
{
Type t = cppu::UnoType<decltype(re)>::get();
OUString message = t.getTypeName() + re.Message;
return message;
}
OUString GetErrorMessage( const Exception& e )
{
Type t = cppu::UnoType<decltype(e)>::get();
OUString message = t.getTypeName() + e.Message;
return message;
}
OUString GetErrorMessage( const css::uno::Any& aException ) OUString GetErrorMessage( const css::uno::Any& aException )
{ {
if ( aException.getValueType() == if ( aException.getValueType() ==
@@ -1420,15 +1407,14 @@ OUString GetErrorMessage( const css::uno::Any& aException )
} }
// unknown exception // unknown exception
auto msg = aException.getValueTypeName();
Exception e; Exception e;
RuntimeException rte; if ( (aException >>= e) && !e.Message.isEmpty() )
if ( aException >>= rte )
{ {
return GetErrorMessage( rte ); msg += ": " + e.Message;
} }
return msg;
aException >>= e; }
return GetErrorMessage( e );
} }