From 58d4aeb1ef28adf8547e19b106c09613a954832e Mon Sep 17 00:00:00 2001 From: Tor Lillqvist Date: Tue, 5 May 2020 19:18:56 +0300 Subject: Throw exceptions with useful messages Change-Id: Ic8e09d31db97c0cf2e1aaf006c96481d12deb2d8 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/93506 Tested-by: Jenkins CollaboraOffice Reviewed-by: Tor Lillqvist --- i18npool/source/collator/collator_unicode.cxx | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/i18npool/source/collator/collator_unicode.cxx b/i18npool/source/collator/collator_unicode.cxx index d3e189a5ff1d..b731d8879fed 100644 --- a/i18npool/source/collator/collator_unicode.cxx +++ b/i18npool/source/collator/collator_unicode.cxx @@ -19,6 +19,8 @@ #include +#include + #include #include @@ -139,7 +141,11 @@ Collator_Unicode::loadCollatorAlgorithm(const OUString& rAlgorithm, const lang:: OUString rule = LocaleDataImpl::get()->getCollatorRuleByAlgorithm(rLocale, rAlgorithm); if (!rule.isEmpty()) { collator.reset( new icu::RuleBasedCollator(reinterpret_cast(rule.getStr()), status) ); - if (! U_SUCCESS(status)) throw RuntimeException(); + if (! U_SUCCESS(status)) { + OUString message = "icu::RuleBasedCollator ctor failed: " + OUString::createFromAscii(u_errorName(status)); + SAL_WARN("i18npool", message); + throw RuntimeException(message); + } } if (!collator && OUString(LOCAL_RULE_LANGS).indexOf(rLocale.Language) >= 0) { const sal_uInt8* (*func)() = nullptr; @@ -357,10 +363,18 @@ Collator_Unicode::loadCollatorAlgorithm(const OUString& rAlgorithm, const lang:: uca_base.reset( static_cast(icu::Collator::createInstance( icu::Locale::getRoot(), status)) ); #endif - if (! U_SUCCESS(status)) throw RuntimeException(); + if (! U_SUCCESS(status)) { + OUString message = "icu::Collator::createInstance() failed: " + OUString::createFromAscii(u_errorName(status)); + SAL_WARN("i18npool", message); + throw RuntimeException(message); + } collator.reset( new icu::RuleBasedCollator( reinterpret_cast(ruleImage), ruleImageSize, uca_base.get(), status) ); - if (! U_SUCCESS(status)) throw RuntimeException(); + if (! U_SUCCESS(status)) { + OUString message = "icu::RuleBasedCollator ctor failed: " + OUString::createFromAscii(u_errorName(status)); + SAL_WARN("i18npool", message); + throw RuntimeException(message); + } } } if (!collator) { @@ -381,7 +395,11 @@ Collator_Unicode::loadCollatorAlgorithm(const OUString& rAlgorithm, const lang:: // load ICU collator collator.reset( static_cast( icu::Collator::createInstance(icuLocale, status) ) ); - if (! U_SUCCESS(status)) throw RuntimeException(); + if (! U_SUCCESS(status)) { + OUString message = "icu::Collator::createInstance() failed: " + OUString::createFromAscii(u_errorName(status)); + SAL_WARN("i18npool", message); + throw RuntimeException(); + } } } -- cgit v1.2.3