Skip to content

Commit

Permalink
Update error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
jpalumickas committed Sep 23, 2020
1 parent 289a29d commit 7bd4880
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions main.mm
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,16 @@
Napi::Object obj = Napi::Object::New(env);

obj.Set("hello", "world");
deferred.Resolve(obj);

//NSDictionary *result = [appleLogin initiateLoginProcess:^(NSDictionary * _Nonnull result) {
// deferred.Resolve(result);
//} errorHandler:^(NSError * _Nonnull error) {
// //deferred.Reject(error);
//}];
NSDictionary *result = [appleLogin initiateLoginProcess:^(NSDictionary * _Nonnull result) {
deferred.Resolve(obj);
} errorHandler:^(NSError * _Nonnull error) {
// NSString *nsErr = error.localizedDescription;
NSString *nsErr = [NSString stringWithFormat:@"%@", error];
std::string errMsg = std::string([nsErr UTF8String]);

Napi::Error::New(info.Env(), errMsg).ThrowAsJavaScriptException();
}];

return deferred.Promise();
}
Expand Down

0 comments on commit 7bd4880

Please sign in to comment.