Skip to content

Commit

Permalink
Implemented helper function which passes the error object as a dictio…
Browse files Browse the repository at this point in the history
…nary and takes into account the optional nature of userInfo on NSError
  • Loading branch information
mdescalzo committed May 9, 2023
1 parent 64a7cd3 commit 4be0fc7
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions ios/RNWatch/RNWatch.m
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ - (void) session:(WCSession *)session
activationDidCompleteWithState:(WCSessionActivationState)activationState
error:(NSError *)error {
if (error) {
[self dispatchEventWithName:EVENT_ACTIVATION_ERROR body:@{@"error": error}];
[self dispatchEventWithName:EVENT_ACTIVATION_ERROR body:@{@"error": dictionaryFromError(error)}];
}
}

Expand Down Expand Up @@ -500,7 +500,7 @@ - (void) session:(WCSession *)session
[self.session updateApplicationContext:context error:&error];
if (error) {
NSLog(@"Application context update error: %@ %@", error, [error userInfo]);
[self dispatchEventWithName:EVENT_WATCH_APPLICATION_CONTEXT_ERROR body:@{@"context": context, @"error": [error userInfo]}];
[self dispatchEventWithName:EVENT_WATCH_APPLICATION_CONTEXT_ERROR body:@{@"context": context, @"error": dictionaryFromError(error)}];
}
}

Expand All @@ -527,7 +527,7 @@ - (void) session:(WCSession *)session

if (error) {
NSLog(@"Application context recieve error: %@", error);
[self dispatchEventWithName:EVENT_APPLICATION_CONTEXT_RECEIVED_ERROR body:@{@"error": error}];
[self dispatchEventWithName:EVENT_APPLICATION_CONTEXT_RECEIVED_ERROR body:@{@"error": dictionaryFromError(error)}];
} else {
[self dispatchEventWithName:EVENT_APPLICATION_CONTEXT_RECEIVED body:applicationContext];
}
Expand Down Expand Up @@ -575,7 +575,7 @@ - (void) session:(WCSession *)session
- (void)session:(WCSession *)session didFinishUserInfoTransfer:(WCSessionUserInfoTransfer *)userInfoTransfer error:(NSError *)error {
if (error) {
NSLog(@"User info transfer error: %@ %@", error, [error userInfo]);
[self dispatchEventWithName:EVENT_WATCH_USER_INFO_ERROR body:@{@"userInfo": [userInfoTransfer userInfo], @"error": [error userInfo]}];
[self dispatchEventWithName:EVENT_WATCH_USER_INFO_ERROR body:@{@"userInfo": [userInfoTransfer userInfo], @"error": dictionaryFromError(error)}];
}
}

Expand Down

0 comments on commit 4be0fc7

Please sign in to comment.