From a97ceaf14e294373b864c61c930f8723e13747c7 Mon Sep 17 00:00:00 2001 From: Ankit_Jaipuriar Date: Sun, 24 Sep 2023 11:49:28 +0530 Subject: [PATCH] tdf#42982 Improved UNO API error reporting Change-Id: I62862c8dd83b587e56177afd2ec05af1f567f6ff Reviewed-on: https://gerrit.libreoffice.org/c/core/+/157201 Tested-by: Jenkins Reviewed-by: Mike Kaganski --- .../source/breakiterator/breakiterator_unicode.cxx | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/i18npool/source/breakiterator/breakiterator_unicode.cxx b/i18npool/source/breakiterator/breakiterator_unicode.cxx index 7e19e863bc70..4927a82293fc 100644 --- a/i18npool/source/breakiterator/breakiterator_unicode.cxx +++ b/i18npool/source/breakiterator/breakiterator_unicode.cxx @@ -146,7 +146,8 @@ void BreakIterator_Unicode::loadICUBreakIterator(const css::lang::Locale& rLocal status = U_ZERO_ERROR; udata_setAppData("OpenOffice", OpenOffice_dat, &status); - if ( !U_SUCCESS(status) ) throw uno::RuntimeException(); + if ( !U_SUCCESS(status) ) + throw uno::RuntimeException("udata_setAppData returned error " + OUString::createFromAscii(u_errorName(status))); std::shared_ptr rbi; @@ -273,14 +274,14 @@ void BreakIterator_Unicode::loadICUBreakIterator(const css::lang::Locale& rLocal break; } if ( !U_SUCCESS(status) || !pBI ) { - throw uno::RuntimeException(); + throw uno::RuntimeException("Failed to create ICU BreakIterator: error " + OUString::createFromAscii(u_errorName(status))); } icuBI->mpValue = std::make_shared(); icuBI->mpValue->mpBreakIterator = pBI; theBIMap.insert( std::make_pair( aBIMapLocaleTypeKey, icuBI->mpValue)); } while (false); if (!icuBI->mpValue || !icuBI->mpValue->mpBreakIterator) { - throw uno::RuntimeException(); + throw uno::RuntimeException("ICU BreakIterator is not properly initialized"); } icuBI->maBIMapKey = aBIMapGlobalKey; if (!bInMap) @@ -297,12 +298,12 @@ void BreakIterator_Unicode::loadICUBreakIterator(const css::lang::Locale& rLocal icuBI->mpValue->mpUt = utext_openUChars(icuBI->mpValue->mpUt, pText, rText.getLength(), &status); if (!U_SUCCESS(status)) - throw uno::RuntimeException(); + throw uno::RuntimeException("utext_openUChars returned error " + OUString::createFromAscii(u_errorName(status))); icuBI->mpValue->mpBreakIterator->setText(icuBI->mpValue->mpUt, status); if (!U_SUCCESS(status)) - throw uno::RuntimeException(); + throw uno::RuntimeException("Failed to set text for ICU BreakIterator: error " + OUString::createFromAscii(u_errorName(status))); icuBI->mpValue->maICUText = rText; }