Skip to content
Merged
Changes from all 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,42 @@ - (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" key does not work for removing this object. So we use our own
// String to retrieve
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