mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 05:07:35 +00:00
LibJS: Add name and message properties to NativeError prototypes
Otherwise these will get their name/default message from the Error
prototype, and as a result would always just say "Error" in error
messages, not the specific type.
Something I missed in da177c6
, now with tests. :^)
This commit is contained in:
parent
1aec9a508e
commit
ea60b344eb
4 changed files with 52 additions and 9 deletions
|
@ -90,6 +90,15 @@ JS_DEFINE_NATIVE_FUNCTION(ErrorPrototype::to_string)
|
|||
PrototypeName::PrototypeName(GlobalObject& global_object) \
|
||||
: Object(*global_object.error_prototype()) \
|
||||
{ \
|
||||
} \
|
||||
\
|
||||
void PrototypeName::initialize(GlobalObject& global_object) \
|
||||
{ \
|
||||
auto& vm = this->vm(); \
|
||||
Object::initialize(global_object); \
|
||||
u8 attr = Attribute::Writable | Attribute::Configurable; \
|
||||
define_property(vm.names.name, js_string(vm, #ClassName), attr); \
|
||||
define_property(vm.names.message, js_string(vm, ""), attr); \
|
||||
}
|
||||
|
||||
JS_ENUMERATE_ERROR_SUBCLASSES
|
||||
|
|
|
@ -48,7 +48,7 @@ private:
|
|||
\
|
||||
public: \
|
||||
explicit PrototypeName(GlobalObject&); \
|
||||
virtual void initialize(GlobalObject&) override { } \
|
||||
virtual void initialize(GlobalObject&) override; \
|
||||
virtual ~PrototypeName() override = default; \
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue