Skip to content
This repository was archived by the owner on Feb 22, 2023. It is now read-only.
Closed
Show file tree
Hide file tree
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 @@ -16,6 +16,7 @@
import io.flutter.plugin.common.MethodChannel.MethodCallHandler;
import io.flutter.plugin.common.MethodChannel.Result;
import io.flutter.plugin.common.PluginRegistry.Registrar;
import java.net.SocketTimeoutException;
import java.util.HashMap;
import java.util.Map;

Expand Down Expand Up @@ -55,7 +56,18 @@ public void onComplete(@NonNull Task<HttpsCallableResult> task) {
"functionsError",
"Cloud function failed with exception.",
exceptionMap);
} else {
} else if (task.getException() instanceof SocketTimeoutException) {
SocketTimeoutException exception =
(SocketTimeoutException) task.getException();
Map < String, Object > exceptionMap = new HashMap < > ();
exceptionMap.put("code", FirebaseFunctionsException.Code.DEADLINE_EXCEEDED.name());
exceptionMap.put("message", exception.getMessage());
exceptionMap.put("details", "SocketTimeoutException");
result.error(
"functionsError",
"Cloud function failed with exception.",
exceptionMap);
}else {
Exception exception = task.getException();
result.error(null, exception.getMessage(), null);
}
Expand Down
49 changes: 23 additions & 26 deletions packages/cloud_functions/ios/Classes/CloudFunctionsPlugin.m
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@

#import "CloudFunctionsPlugin.h"

#import "FIRFunctions+Internal.h"
#import "Firebase/Firebase.h"

@interface CloudFunctionsPlugin ()
@property(nonatomic, retain) FlutterMethodChannel *_channel;
@property(strong, nonatomic) FIRFunctions *functions;
@end

@implementation CloudFunctionsPlugin
Expand All @@ -35,36 +35,33 @@ - (void)handleMethodCall:(FlutterMethodCall *)call result:(FlutterResult)result
if ([@"CloudFunctions#call" isEqualToString:call.method]) {
NSString *functionName = call.arguments[@"functionName"];
NSObject *parameters = call.arguments[@"parameters"];
[[FIRFunctions functions]
callFunction:functionName
withObject:parameters
completion:^(FIRHTTPSCallableResult *callableResult, NSError *error) {
if (error) {
[[_functions HTTPSCallableWithName:functionName] callWithObject:parameters completion:^(FIRHTTPSCallableResult * _Nullable callRresult, NSError * _Nullable error) {
if (error) {
FlutterError *flutterError;
if (error.domain == FIRFunctionsErrorDomain) {
NSDictionary *details = [NSMutableDictionary dictionary];
[details setValue:[self mapFunctionsErrorCodes:error.code] forKey:@"code"];
if (error.localizedDescription != nil) {
[details setValue:error.localizedDescription forKey:@"message"];
}
if (error.userInfo[FIRFunctionsErrorDetailsKey] != nil) {
[details setValue:error.userInfo[FIRFunctionsErrorDetailsKey] forKey:@"details"];
}

flutterError =
[FlutterError errorWithCode:@"functionsError"
message:@"Firebase function failed with exception."
details:details];
NSDictionary *details = [NSMutableDictionary dictionary];
[details setValue:[self mapFunctionsErrorCodes:error.code] forKey:@"code"];
if (error.localizedDescription != nil) {
[details setValue:error.localizedDescription forKey:@"message"];
}
if (error.userInfo[FIRFunctionsErrorDetailsKey] != nil) {
[details setValue:error.userInfo[FIRFunctionsErrorDetailsKey] forKey:@"details"];
}
flutterError =
[FlutterError errorWithCode:@"functionsError"
message:@"Firebase function failed with exception."
details:details];
} else {
flutterError = [FlutterError errorWithCode:nil
message:error.localizedDescription
details:nil];
flutterError = [FlutterError errorWithCode:nil
message:error.localizedDescription
details:nil];
}
result(flutterError);
} else {
result(callableResult.data);
}
}];
} else {
result(callRresult.data);
}
}];
} else {
result(FlutterMethodNotImplemented);
}
Expand Down