diff options
author | Linus Groh <mail@linusgroh.de> | 2021-06-11 18:06:20 +0100 |
---|---|---|
committer | Linus Groh <mail@linusgroh.de> | 2021-06-11 18:49:50 +0100 |
commit | cbd7437d40c6d58c475938e45ffa4265dbbc5ac0 (patch) | |
tree | 26a977d1addf64c514bf42516def408ca4f12bcb /Userland/Libraries/LibJS/Runtime/AggregateError.cpp | |
parent | 2f03eb8628dbb2d6c643c09309d92237dd0152fc (diff) | |
download | serenity-cbd7437d40c6d58c475938e45ffa4265dbbc5ac0.zip |
LibJS: Implement AggregateError
Diffstat (limited to 'Userland/Libraries/LibJS/Runtime/AggregateError.cpp')
-rw-r--r-- | Userland/Libraries/LibJS/Runtime/AggregateError.cpp | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/Userland/Libraries/LibJS/Runtime/AggregateError.cpp b/Userland/Libraries/LibJS/Runtime/AggregateError.cpp new file mode 100644 index 0000000000..7b8110c127 --- /dev/null +++ b/Userland/Libraries/LibJS/Runtime/AggregateError.cpp @@ -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) +{ +} + +} |