mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 14:47:44 +00:00
LibJS: Move install_error_cause() from Object to Error
This is only used by Error and its subclasses, so it doesn't need to be available to all objects.
This commit is contained in:
parent
a63cc2c6b9
commit
dbda5a9a4c
4 changed files with 17 additions and 17 deletions
|
@ -29,6 +29,21 @@ Error::Error(Object& prototype)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 20.5.8.1 InstallErrorCause ( O, options ), https://tc39.es/proposal-error-cause/#sec-errorobjects-install-error-cause
|
||||||
|
void Error::install_error_cause(Value options)
|
||||||
|
{
|
||||||
|
auto& vm = this->vm();
|
||||||
|
if (!options.is_object())
|
||||||
|
return;
|
||||||
|
auto& options_object = options.as_object();
|
||||||
|
if (!options_object.has_property(vm.names.cause))
|
||||||
|
return;
|
||||||
|
auto cause = options_object.get(vm.names.cause).value_or(js_undefined());
|
||||||
|
if (vm.exception())
|
||||||
|
return;
|
||||||
|
define_property(vm.names.cause, cause, Attribute::Writable | Attribute::Configurable);
|
||||||
|
}
|
||||||
|
|
||||||
#define __JS_ENUMERATE(ClassName, snake_name, PrototypeName, ConstructorName, ArrayType) \
|
#define __JS_ENUMERATE(ClassName, snake_name, PrototypeName, ConstructorName, ArrayType) \
|
||||||
ClassName* ClassName::create(GlobalObject& global_object) \
|
ClassName* ClassName::create(GlobalObject& global_object) \
|
||||||
{ \
|
{ \
|
||||||
|
|
|
@ -21,6 +21,8 @@ public:
|
||||||
|
|
||||||
explicit Error(Object& prototype);
|
explicit Error(Object& prototype);
|
||||||
virtual ~Error() override = default;
|
virtual ~Error() override = default;
|
||||||
|
|
||||||
|
void install_error_cause(Value options);
|
||||||
};
|
};
|
||||||
|
|
||||||
// NOTE: Making these inherit from Error is not required by the spec but
|
// NOTE: Making these inherit from Error is not required by the spec but
|
||||||
|
|
|
@ -1125,21 +1125,6 @@ Value Object::ordinary_to_primitive(Value::PreferredType preferred_type) const
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
// 20.5.8.1 InstallErrorCause ( O, options ), https://tc39.es/proposal-error-cause/#sec-errorobjects-install-error-cause
|
|
||||||
void Object::install_error_cause(Value options)
|
|
||||||
{
|
|
||||||
auto& vm = this->vm();
|
|
||||||
if (!options.is_object())
|
|
||||||
return;
|
|
||||||
auto& options_object = options.as_object();
|
|
||||||
if (!options_object.has_property(vm.names.cause))
|
|
||||||
return;
|
|
||||||
auto cause = options_object.get(vm.names.cause).value_or(js_undefined());
|
|
||||||
if (vm.exception())
|
|
||||||
return;
|
|
||||||
define_property(vm.names.cause, cause, Attribute::Writable | Attribute::Configurable);
|
|
||||||
}
|
|
||||||
|
|
||||||
Value Object::invoke_internal(const StringOrSymbol& property_name, Optional<MarkedValueList> arguments)
|
Value Object::invoke_internal(const StringOrSymbol& property_name, Optional<MarkedValueList> arguments)
|
||||||
{
|
{
|
||||||
auto& vm = this->vm();
|
auto& vm = this->vm();
|
||||||
|
|
|
@ -135,8 +135,6 @@ public:
|
||||||
IndexedProperties& indexed_properties() { return m_indexed_properties; }
|
IndexedProperties& indexed_properties() { return m_indexed_properties; }
|
||||||
void set_indexed_property_elements(Vector<Value>&& values) { m_indexed_properties = IndexedProperties(move(values)); }
|
void set_indexed_property_elements(Vector<Value>&& values) { m_indexed_properties = IndexedProperties(move(values)); }
|
||||||
|
|
||||||
void install_error_cause(Value options);
|
|
||||||
|
|
||||||
[[nodiscard]] Value invoke_internal(const StringOrSymbol& property_name, Optional<MarkedValueList> arguments);
|
[[nodiscard]] Value invoke_internal(const StringOrSymbol& property_name, Optional<MarkedValueList> arguments);
|
||||||
|
|
||||||
template<typename... Args>
|
template<typename... Args>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue