summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibJS/Runtime/ErrorConstructor.h
diff options
context:
space:
mode:
authorLinus Groh <mail@linusgroh.de>2021-04-12 00:08:28 +0200
committerAndreas Kling <kling@serenityos.org>2021-04-12 09:38:57 +0200
commitda177c6517ab0ba77facfe4ff5a078562f887e96 (patch)
tree33123a6ad6e98f09b4390796dc20f26458c0800e /Userland/Libraries/LibJS/Runtime/ErrorConstructor.h
parent6e9eb0a284661803d634ce0bd8c1656a156878bb (diff)
downloadserenity-da177c6517ab0ba77facfe4ff5a078562f887e96.zip
LibJS: Make Errors fully spec compliant
The previous handling of the name and message properties specifically was breaking websites that created their own error types and relied on the error prototype working correctly - not assuming an JS::Error this object, that is. The way it works now, and it is supposed to work, is: - Error.prototype.name and Error.prototype.message just have initial string values and are no longer getters/setters - When constructing an error with a message, we create a regular property on the newly created object, so a lookup of the message property will either get it from the object directly or go though the prototype chain - Internal m_name/m_message properties are no longer needed and removed This makes printing errors slightly more complicated, as we can no longer rely on the (safe) internal properties, and cannot trust a property lookup either - get_without_side_effects() is used to solve this, it's not perfect but something we can revisit later. I did some refactoring along the way, there was some really old stuff in there - accessing vm.call_frame().arguments[0] is not something we (have to) do anymore :^) Fixes #6245.
Diffstat (limited to 'Userland/Libraries/LibJS/Runtime/ErrorConstructor.h')
-rw-r--r--Userland/Libraries/LibJS/Runtime/ErrorConstructor.h4
1 files changed, 2 insertions, 2 deletions
diff --git a/Userland/Libraries/LibJS/Runtime/ErrorConstructor.h b/Userland/Libraries/LibJS/Runtime/ErrorConstructor.h
index 2626623aaa..c24cca73cb 100644
--- a/Userland/Libraries/LibJS/Runtime/ErrorConstructor.h
+++ b/Userland/Libraries/LibJS/Runtime/ErrorConstructor.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2020, Linus Groh <mail@linusgroh.de>
+ * Copyright (c) 2020-2021, Linus Groh <mail@linusgroh.de>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -37,7 +37,7 @@ class ErrorConstructor final : public NativeFunction {
public:
explicit ErrorConstructor(GlobalObject&);
virtual void initialize(GlobalObject&) override;
- virtual ~ErrorConstructor() override;
+ virtual ~ErrorConstructor() override = default;
virtual Value call() override;
virtual Value construct(Function& new_target) override;