MCPcopy Index your code
hub / github.com/nodejs/node-addon-api / CatchMethod

Function CatchMethod

test/promise.cc:79–93  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

77}
78
79Value CatchMethod(const CallbackInfo& info) {
80 auto deferred = Promise::Deferred::New(info.Env());
81 Function onRejected = info[0].As<Function>();
82
83 Promise resultPromise = MaybeUnwrap(deferred.Promise().Catch(onRejected));
84
85 bool isPromise = resultPromise.IsPromise();
86 deferred.Reject(String::New(info.Env(), "Rejected"));
87
88 Object result = Object::New(info.Env());
89 result["isPromise"] = Boolean::New(info.Env(), isPromise);
90 result["promise"] = resultPromise;
91
92 return result;
93}
94
95Object InitPromise(Env env) {
96 Object exports = Object::New(env);

Callers

nothing calls this directly

Calls 5

MaybeUnwrapFunction · 0.85
EnvMethod · 0.80
CatchMethod · 0.80
PromiseMethod · 0.80
RejectMethod · 0.80

Tested by

no test coverage detected