diff --git a/iOS/SimpleAuthWrapper.m b/iOS/SimpleAuthWrapper.m index c631d8e..d74350b 100644 --- a/iOS/SimpleAuthWrapper.m +++ b/iOS/SimpleAuthWrapper.m @@ -32,10 +32,18 @@ @implementation SimpleAuthWrapper callback(@[[NSNull null], token, [extra objectForKey: @"raw_info"]]); } else { if (error) { + NSMutableDictionary *dict=[NSMutableDictionary dictionaryWithCapacity:1]; + [dict setObject:[NSNumber numberWithInteger:error.code] forKey:@"code"]; + + // Add an error description, if it exists. NSDictionary *userInfo = [error userInfo]; - NSString *errorString = [[userInfo objectForKey:NSUnderlyingErrorKey] localizedDescription]; - NSDictionary *dict=@{@"code": [NSNumber numberWithInteger:error.code], - @"description": errorString}; + if (userInfo) { + NSString *errorString = [[userInfo objectForKey:NSUnderlyingErrorKey] localizedDescription]; + if (errorString) { + [dict setObject:errorString forKey:@"description"]; + } + } + callback(@[dict]); } else { callback(@[@true]);