mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 08:47:34 +00:00
LibJS: Remove duplicated error message from ErrorTypes.h
ErrorType::IntlInvalidCode has almost exactly the same message as ErrorType::OptionIsNotValidValue. Remove it, as all uses of the former are semantically interchangeable with the latter.
This commit is contained in:
parent
21c4922ac0
commit
fdedb3ab33
3 changed files with 8 additions and 9 deletions
|
@ -31,7 +31,6 @@
|
||||||
M(InOperatorWithObject, "'in' operator must be used on an object") \
|
M(InOperatorWithObject, "'in' operator must be used on an object") \
|
||||||
M(InstanceOfOperatorBadPrototype, "'prototype' property of {} is not an object") \
|
M(InstanceOfOperatorBadPrototype, "'prototype' property of {} is not an object") \
|
||||||
M(IntlInvalidLanguageTag, "{} is not a structurally valid language tag") \
|
M(IntlInvalidLanguageTag, "{} is not a structurally valid language tag") \
|
||||||
M(IntlInvalidCode, "'{}' is not a valid value for option type {}") \
|
|
||||||
M(InvalidAssignToConst, "Invalid assignment to const variable") \
|
M(InvalidAssignToConst, "Invalid assignment to const variable") \
|
||||||
M(InvalidCodePoint, "Invalid code point {}, must be an integer no less than 0 and no greater than 0x10FFFF") \
|
M(InvalidCodePoint, "Invalid code point {}, must be an integer no less than 0 and no greater than 0x10FFFF") \
|
||||||
M(InvalidFormat, "Invalid {} format") \
|
M(InvalidFormat, "Invalid {} format") \
|
||||||
|
|
|
@ -445,7 +445,7 @@ Value canonical_code_for_display_names(GlobalObject& global_object, DisplayNames
|
||||||
if (type == DisplayNames::Type::Language) {
|
if (type == DisplayNames::Type::Language) {
|
||||||
// a. If code does not match the unicode_language_id production, throw a RangeError exception.
|
// a. If code does not match the unicode_language_id production, throw a RangeError exception.
|
||||||
if (!Unicode::parse_unicode_language_id(code).has_value()) {
|
if (!Unicode::parse_unicode_language_id(code).has_value()) {
|
||||||
vm.throw_exception<RangeError>(global_object, ErrorType::IntlInvalidCode, code, "language"sv);
|
vm.throw_exception<RangeError>(global_object, ErrorType::OptionIsNotValidValue, code, "language"sv);
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -466,7 +466,7 @@ Value canonical_code_for_display_names(GlobalObject& global_object, DisplayNames
|
||||||
if (type == DisplayNames::Type::Region) {
|
if (type == DisplayNames::Type::Region) {
|
||||||
// a. If code does not match the unicode_region_subtag production, throw a RangeError exception.
|
// a. If code does not match the unicode_region_subtag production, throw a RangeError exception.
|
||||||
if (!Unicode::is_unicode_region_subtag(code)) {
|
if (!Unicode::is_unicode_region_subtag(code)) {
|
||||||
vm.throw_exception<RangeError>(global_object, ErrorType::IntlInvalidCode, code, "region"sv);
|
vm.throw_exception<RangeError>(global_object, ErrorType::OptionIsNotValidValue, code, "region"sv);
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -479,7 +479,7 @@ Value canonical_code_for_display_names(GlobalObject& global_object, DisplayNames
|
||||||
if (type == DisplayNames::Type::Script) {
|
if (type == DisplayNames::Type::Script) {
|
||||||
// a. If code does not match the unicode_script_subtag production, throw a RangeError exception.
|
// a. If code does not match the unicode_script_subtag production, throw a RangeError exception.
|
||||||
if (!Unicode::is_unicode_script_subtag(code)) {
|
if (!Unicode::is_unicode_script_subtag(code)) {
|
||||||
vm.throw_exception<RangeError>(global_object, ErrorType::IntlInvalidCode, code, "script"sv);
|
vm.throw_exception<RangeError>(global_object, ErrorType::OptionIsNotValidValue, code, "script"sv);
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -493,7 +493,7 @@ Value canonical_code_for_display_names(GlobalObject& global_object, DisplayNames
|
||||||
|
|
||||||
// 5. If ! IsWellFormedCurrencyCode(code) is false, throw a RangeError exception.
|
// 5. If ! IsWellFormedCurrencyCode(code) is false, throw a RangeError exception.
|
||||||
if (!is_well_formed_currency_code(code)) {
|
if (!is_well_formed_currency_code(code)) {
|
||||||
vm.throw_exception<RangeError>(global_object, ErrorType::IntlInvalidCode, code, "currency"sv);
|
vm.throw_exception<RangeError>(global_object, ErrorType::OptionIsNotValidValue, code, "currency"sv);
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,25 +2,25 @@ describe("errors", () => {
|
||||||
test("invalid language", () => {
|
test("invalid language", () => {
|
||||||
expect(() => {
|
expect(() => {
|
||||||
new Intl.DisplayNames("en", { type: "language" }).of("hello!");
|
new Intl.DisplayNames("en", { type: "language" }).of("hello!");
|
||||||
}).toThrowWithMessage(RangeError, "'hello!' is not a valid value for option type language");
|
}).toThrowWithMessage(RangeError, "hello! is not a valid value for option language");
|
||||||
});
|
});
|
||||||
|
|
||||||
test("invalid region", () => {
|
test("invalid region", () => {
|
||||||
expect(() => {
|
expect(() => {
|
||||||
new Intl.DisplayNames("en", { type: "region" }).of("hello!");
|
new Intl.DisplayNames("en", { type: "region" }).of("hello!");
|
||||||
}).toThrowWithMessage(RangeError, "'hello!' is not a valid value for option type region");
|
}).toThrowWithMessage(RangeError, "hello! is not a valid value for option region");
|
||||||
});
|
});
|
||||||
|
|
||||||
test("invalid script", () => {
|
test("invalid script", () => {
|
||||||
expect(() => {
|
expect(() => {
|
||||||
new Intl.DisplayNames("en", { type: "script" }).of("hello!");
|
new Intl.DisplayNames("en", { type: "script" }).of("hello!");
|
||||||
}).toThrowWithMessage(RangeError, "'hello!' is not a valid value for option type script");
|
}).toThrowWithMessage(RangeError, "hello! is not a valid value for option script");
|
||||||
});
|
});
|
||||||
|
|
||||||
test("invalid currency", () => {
|
test("invalid currency", () => {
|
||||||
expect(() => {
|
expect(() => {
|
||||||
new Intl.DisplayNames("en", { type: "currency" }).of("hello!");
|
new Intl.DisplayNames("en", { type: "currency" }).of("hello!");
|
||||||
}).toThrowWithMessage(RangeError, "'hello!' is not a valid value for option type currency");
|
}).toThrowWithMessage(RangeError, "hello! is not a valid value for option currency");
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue