mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 23:17:45 +00:00
LibJS: Implement AggregateError
This commit is contained in:
parent
2f03eb8628
commit
cbd7437d40
13 changed files with 301 additions and 15 deletions
29
Userland/Libraries/LibJS/Runtime/AggregateError.cpp
Normal file
29
Userland/Libraries/LibJS/Runtime/AggregateError.cpp
Normal file
|
@ -0,0 +1,29 @@
|
|||
/*
|
||||
* Copyright (c) 2021, Linus Groh <linusg@serenityos.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <LibJS/Runtime/AggregateError.h>
|
||||
#include <LibJS/Runtime/Array.h>
|
||||
#include <LibJS/Runtime/GlobalObject.h>
|
||||
|
||||
namespace JS {
|
||||
|
||||
AggregateError* AggregateError::create(GlobalObject& global_object, String const& message, Vector<Value> const& errors)
|
||||
{
|
||||
auto& vm = global_object.vm();
|
||||
auto* error = global_object.heap().allocate<AggregateError>(global_object, *global_object.aggregate_error_prototype());
|
||||
u8 attr = Attribute::Writable | Attribute::Configurable;
|
||||
if (!message.is_null())
|
||||
error->define_property(vm.names.message, js_string(vm, message), attr);
|
||||
error->define_property(vm.names.errors, Array::create_from(global_object, errors), attr);
|
||||
return error;
|
||||
}
|
||||
|
||||
AggregateError::AggregateError(Object& prototype)
|
||||
: Object(prototype)
|
||||
{
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue