1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 04:17:35 +00:00

LibJS: Convert has_property() to ThrowCompletionOr

This commit is contained in:
Linus Groh 2021-10-03 02:00:39 +01:00
parent a29b7a3ec7
commit f38a5957bf
11 changed files with 53 additions and 135 deletions

View file

@ -36,12 +36,7 @@ ThrowCompletionOr<void> Error::install_error_cause(Value options)
auto& vm = this->vm();
// 1. If Type(options) is Object and ? HasProperty(options, "cause") is true, then
if (!options.is_object())
return {};
auto has_property = options.as_object().has_property(vm.names.cause);
if (auto* exception = vm.exception())
return throw_completion(exception->value());
if (has_property) {
if (options.is_object() && TRY(options.as_object().has_property(vm.names.cause))) {
// a. Let cause be ? Get(options, "cause").
auto cause = TRY(options.as_object().get(vm.names.cause));