summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTor Lillqvist <tml@collabora.com>2020-05-05 19:18:56 +0300
committerTor Lillqvist <tml@collabora.com>2020-05-06 07:01:52 +0200
commit58d4aeb1ef28adf8547e19b106c09613a954832e (patch)
treee191c9ec105e4fa5649277eac73fbe4d92b1e8a6
parent3413859dd7a7503e09c1d9b110dbb45c52fe7e01 (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>
-rw-r--r--i18npool/source/collator/collator_unicode.cxx26
1 files 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 <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();
+ }
}
}