Skip to content
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -123,22 +123,41 @@ - (void)handleMethodCall:(FlutterMethodCall *)call result:(FlutterResult)result
FLTFirebaseMethodCallErrorBlock errorBlock = ^(
NSString *_Nullable code, NSString *_Nullable message, NSDictionary *_Nullable details,
NSError *_Nullable error) {
NSMutableDictionary *temp;
if (code == nil) {
NSDictionary *errorDetails = getDictionaryFromNSError(error);
code = errorDetails[kCode];
message = errorDetails[kMessage];
details = errorDetails;

if (errorDetails[@"additionalData"] != nil) {
temp = [errorDetails[@"additionalData"] mutableCopy];
} else {
temp = [errorDetails mutableCopy];
}

// "NSErrorFailingURLStringKey" doesn't work
Comment thread
russellwheatley marked this conversation as resolved.
Outdated
if (temp[@"NSErrorFailingURLKey"] != nil) {
[temp removeObjectForKey:@"NSErrorFailingURLKey"];
}
if (temp[NSUnderlyingErrorKey] != nil) {
[temp removeObjectForKey:NSUnderlyingErrorKey];
}

if ([errorDetails[kMessage] containsString:@"An unknown error has occurred"] &&
[temp[NSLocalizedDescriptionKey] containsString:@"The request timed out"]) {
message = temp[NSLocalizedDescriptionKey];
}

if (errorDetails[@"additionalData"][NSLocalizedFailureReasonErrorKey] != nil) {
// This stops an uncaught type cast exception in dart
NSMutableDictionary *temp = [errorDetails[@"additionalData"] mutableCopy];
[temp removeObjectForKey:NSLocalizedFailureReasonErrorKey];
details = temp;
// provides a useful message to the user. e.g. "Universal link URL could not be parsed".
if ([message containsString:@"unknown error"]) {
message = errorDetails[@"additionalData"][NSLocalizedFailureReasonErrorKey];
}
}

details = temp;
} else {
details = @{
kCode : code,
Expand Down