Skip to content

Commit 79c3c0a

Browse files
committed
feat(ios): enhance updateUser error messages with detailed diagnostics
Improve error messages returned from updateUser by including: - Error code and domain for easier debugging - Descriptive error message with context - Underlying error details when available This change is purely additive - it preserves all original error properties and maintains NSNull safety through removeNullUnderlyingError. Before: "Error in updateUser" After: "updateUser failed with error code -1012: Response body is empty for HTTP 200. Domain: io.intercom.ios.error.network"
1 parent 7320f94 commit 79c3c0a

File tree

1 file changed

+23
-1
lines changed

1 file changed

+23
-1
lines changed

ios/IntercomModule.m

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,29 @@ - (NSData *)dataFromHexString:(NSString *)string {
152152
[Intercom updateUser:userAttributes success:^{
153153
resolve(@(YES));
154154
} failure:^(NSError * _Nonnull error) {
155-
failureCallback(UPDATE_USER, @"Error in updateUser", [self removeNullUnderlyingError:error]);
155+
NSString *errorMessage = [NSString stringWithFormat:@"updateUser failed with error code %ld: %@. Domain: %@",
156+
(long)error.code,
157+
error.localizedDescription ?: @"<no description>",
158+
error.domain ?: @"<no domain>"];
159+
160+
NSMutableDictionary *userInfo = [NSMutableDictionary dictionaryWithDictionary:error.userInfo ?: @{}];
161+
userInfo[@"detailedMessage"] = errorMessage;
162+
userInfo[@"errorCode"] = @(error.code);
163+
userInfo[@"errorDomain"] = error.domain ?: @"";
164+
165+
if (error.userInfo[@"NSUnderlyingError"]) {
166+
NSError *underlyingError = error.userInfo[@"NSUnderlyingError"];
167+
if (![underlyingError isKindOfClass:[NSNull class]]) {
168+
userInfo[@"underlyingErrorDescription"] = underlyingError.localizedDescription ?: @"";
169+
userInfo[@"underlyingErrorCode"] = @(underlyingError.code);
170+
}
171+
}
172+
173+
NSError *enrichedError = [NSError errorWithDomain:error.domain
174+
code:error.code
175+
userInfo:userInfo];
176+
177+
failureCallback(UPDATE_USER, errorMessage, [self removeNullUnderlyingError:enrichedError]);
156178
}];
157179
};
158180

0 commit comments

Comments
 (0)