Bug 1201468: Map UErrorCode to nsresult, r=jfkthame

This commit is contained in:
Simon Montagu 2015-10-06 02:59:00 -07:00
Родитель 1a9cfec14b
Коммит 5e7980e26f
2 изменённых файлов: 24 добавлений и 0 удалений

Просмотреть файл

@ -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)

Просмотреть файл

@ -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.