i18npool/source/collator/collator_unicode.cxx | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-)
New commits: commit 58d4aeb1ef28adf8547e19b106c09613a954832e Author: Tor Lillqvist <t...@collabora.com> AuthorDate: Tue May 5 19:18:56 2020 +0300 Commit: Tor Lillqvist <t...@collabora.com> CommitDate: Wed May 6 07:01:52 2020 +0200 Throw exceptions with useful messages Change-Id: Ic8e09d31db97c0cf2e1aaf006c96481d12deb2d8 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/93506 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com> Reviewed-by: Tor Lillqvist <t...@collabora.com> 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 <config_locales.h> +#include <sal/log.hxx> + #include <lrl_include.hxx> #include <rtl/ustrbuf.hxx> @@ -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<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; @@ -357,10 +363,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) { @@ -381,7 +395,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(); + } } } _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits