mirror of
https://gitee.com/openharmony/global_i18n
synced 2024-11-30 18:51:33 +00:00
fix removePreferredLanguage interface
Signed-off-by: sunyaozu <sunyaozu@huawei.com>
This commit is contained in:
parent
ebdad44292
commit
f20aff0083
@ -3011,15 +3011,13 @@ napi_value I18nAddon::RemovePreferredLanguageImpl(napi_env env, napi_callback_in
|
||||
return nullptr;
|
||||
}
|
||||
len = static_cast<int>(PreferredLanguage::GetPreferredLanguageList().size());
|
||||
if (index < 0 || index > len - 1) {
|
||||
if ((index < 0 || index > len - 1) && throwError) {
|
||||
ErrorUtil::NapiThrow(env, I18N_NOT_VALID, throwError);
|
||||
return nullptr;
|
||||
}
|
||||
bool success = PreferredLanguage::RemovePreferredLanguage(index);
|
||||
if (throwError) {
|
||||
if (!success) {
|
||||
ErrorUtil::NapiThrow(env, I18N_NO_PERMISSION, throwError);
|
||||
}
|
||||
if (!success && throwError) {
|
||||
ErrorUtil::NapiThrow(env, I18N_NO_PERMISSION, throwError);
|
||||
return nullptr;
|
||||
}
|
||||
napi_value result = nullptr;
|
||||
|
Loading…
Reference in New Issue
Block a user