There is something additional to mention here, because the bool Set()
function has been deprecated in recent versions of V8, and replaced
with Maybe<bool>. The header says:
* If an API method returns a MaybeLocal<>, the API method can potentially fail
* either because an exception is thrown, or because an exception is pending,
* e.g. because a previous API call threw an exception that hasn't been caught
* yet, or because a TerminateExecution exception was thrown. In that case, an
* empty MaybeLocal is returned.
Specially how Object::Set is handled, you can just read the source in api.cc:
Maybe<bool> v8::Object::Set(v8::Local<v8::Context> context,
v8::Local<Value> key, v8::Local<Value> value) {
PREPARE_FOR_EXECUTION_PRIMITIVE(context, "v8::Object::Set()", bool);
auto self = Utils::OpenHandle(this);
auto key_obj = Utils::OpenHandle(*key);
auto value_obj = Utils::OpenHandle(*value);
has_pending_exception =
i::Runtime::SetObjectProperty(isolate, self, key_obj, value_obj,
i::SLOPPY).is_null();
RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool);
return Just(true);
}
bool v8::Object::Set(v8::Local<Value> key, v8::Local<Value> value) {
auto context = ContextFromHeapObject(Utils::OpenHandle(this));
return Set(context, key, value).FromMaybe(false);
}
So it seems from a quick read, the Maybe API will either return a
non-empty True (Just<true>), or an empty Maybe. The old deprecated
bool Set() will convert that to a true/false, the false in the
FromMaybe(false) is the value for when the Maybe is empty.
So to answer your original question, false means that an exception was
throw or is pending, and it's up to you what you want to do with that
exception.
> --
> --
> v8-users mailing list
>
v8-u...@googlegroups.com
>
http://groups.google.com/group/v8-users
> ---
> You received this message because you are subscribed to the Google Groups
> "v8-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to
v8-users+u...@googlegroups.com.
> For more options, visit
https://groups.google.com/d/optout.