mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 16:18:12 +00:00
LibJS: Implement Error.prototype.name setter (#1776)
The MDN example for creating a custom error type in javascript uses: function CustomError(foo, message, fileName, lineNumber) { var instance = new Error(message, fileName, lineNumber); instance.name = 'CustomError'; instance.foo = foo; Object.setPrototypeOf(instance, Object.getPrototypeOf(this)); return instance; } The name property on the Error prototype needs to be settable for this to work properly.
This commit is contained in:
parent
984c290ec0
commit
2a65db7c12
4 changed files with 30 additions and 1 deletions
|
@ -39,6 +39,8 @@ public:
|
|||
const FlyString& name() const { return m_name; }
|
||||
const String& message() const { return m_message; }
|
||||
|
||||
void set_name(const FlyString& name) { m_name = name; }
|
||||
|
||||
private:
|
||||
virtual bool is_error() const final { return true; }
|
||||
virtual const char* class_name() const override { return "Error"; }
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue