mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-28 15:28:55 +00:00
LibJS: Consolidate error messages into ErrorTypes.h
Now, exceptions can be thrown with interpreter.throw_exception<T>(ErrorType:TYPE, "format", "args", "here").
This commit is contained in:
parent
9940a7f6de
commit
78155a6668
Notes:
sideshowbarker
2024-07-19 05:43:14 +09:00
Author: https://github.com/mattco98
Commit: 78155a6668
Pull-request: https://github.com/SerenityOS/serenity/pull/2538
Issue: https://github.com/SerenityOS/serenity/issues/1842
63 changed files with 439 additions and 223 deletions
|
@ -51,7 +51,7 @@ void Reference::put(Interpreter& interpreter, Value value)
|
|||
}
|
||||
|
||||
if (!base().is_object() && interpreter.in_strict_mode()) {
|
||||
interpreter.throw_exception<TypeError>(String::format("Can't assign property %s to primitive value", m_name.to_string().characters()));
|
||||
interpreter.throw_exception<TypeError>(ErrorType::ReferencePrimitiveAssignment, m_name.to_string().characters());
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -66,11 +66,11 @@ void Reference::throw_reference_error(Interpreter& interpreter)
|
|||
{
|
||||
auto property_name = m_name.to_string();
|
||||
String message;
|
||||
if (property_name.is_empty())
|
||||
message = "Unresolvable reference";
|
||||
else
|
||||
message = String::format("'%s' not known", property_name.characters());
|
||||
interpreter.throw_exception<ReferenceError>(message);
|
||||
if (property_name.is_empty()) {
|
||||
interpreter.throw_exception<ReferenceError>(ErrorType::ReferenceUnresolvable);
|
||||
} else {
|
||||
interpreter.throw_exception<ReferenceError>(ErrorType::UnknownIdentifier, property_name.characters());
|
||||
}
|
||||
}
|
||||
|
||||
Value Reference::get(Interpreter& interpreter)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue