diff options
author | Tor Lillqvist <tml@collabora.com> | 2020-05-05 19:18:56 +0300 |
---|---|---|
committer | Tor Lillqvist <tml@collabora.com> | 2020-05-06 23:47:39 +0200 |
commit | df283b12a95d80a82aa2c2c9b8d32888a4d4039e (patch) | |
tree | 2751263206c2f184dbbdf81bf677a1adf2b0bc53 /i18npool | |
parent | 6b75874386b7b1ec44f7acc49cd3556a56108ed8 (diff) |
Throw exceptions with useful messages
Change-Id: Ic8e09d31db97c0cf2e1aaf006c96481d12deb2d8
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/93506
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Tor Lillqvist <tml@collabora.com>
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/93592
Tested-by: Jenkins
Diffstat (limited to 'i18npool')
-rw-r--r-- | i18npool/source/collator/collator_unicode.cxx | 26 |
1 files changed, 22 insertions, 4 deletions
diff --git a/i18npool/source/collator/collator_unicode.cxx b/i18npool/source/collator/collator_unicode.cxx index 609ef0f20351..673f5c35d3c7 100644 --- a/i18npool/source/collator/collator_unicode.cxx +++ b/i18npool/source/collator/collator_unicode.cxx @@ -19,6 +19,8 @@ #include <config_locales.h> +#include <sal/log.hxx> + #include <lrl_include.hxx> #include <rtl/ustrbuf.hxx> @@ -141,7 +143,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<const UChar *>(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; @@ -359,10 +365,18 @@ Collator_Unicode::loadCollatorAlgorithm(const OUString& rAlgorithm, const lang:: uca_base.reset( static_cast<icu::RuleBasedCollator*>(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<const uint8_t*>(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) { @@ -383,7 +397,11 @@ Collator_Unicode::loadCollatorAlgorithm(const OUString& rAlgorithm, const lang:: // load ICU collator collator.reset( static_cast<icu::RuleBasedCollator*>( 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(message); + } } } |