Bug 1201468: Map UErrorCode to nsresult, r=jfkthame

This commit is contained in:
Simon Montagu 2015-10-06 02:59:00 -07:00
parent b230f97ae2
commit 27c606be55
2 changed files with 24 additions and 0 deletions

View File

@ -175,6 +175,25 @@ ICUUtils::AssignUCharArrayToString(UChar* aICUString,
NS_ASSERTION((int32_t)aMozString.Length() == aLength, "Conversion failed");
}
/* static */ nsresult
ICUUtils::UErrorToNsResult(const UErrorCode aErrorCode)
{
if (U_SUCCESS(aErrorCode)) {
return NS_OK;
}
switch(aErrorCode) {
case U_ILLEGAL_ARGUMENT_ERROR:
return NS_ERROR_INVALID_ARG;
case U_MEMORY_ALLOCATION_ERROR:
return NS_ERROR_OUT_OF_MEMORY;
default:
return NS_ERROR_FAILURE;
}
}
#if 0
/* static */ Locale
ICUUtils::BCP47CodeToLocale(const nsAString& aBCP47Code)

View File

@ -88,6 +88,11 @@ public:
int32_t aLength,
nsAString& aMozString);
/**
* Map ICU UErrorCode to nsresult
*/
static nsresult UErrorToNsResult(const UErrorCode aErrorCode);
#if 0
// Currently disabled because using C++ API doesn't play nicely with enabling
// system ICU.