From 400243d9ae53664914017c26b2e04181502c8ad2 Mon Sep 17 00:00:00 2001 From: Tim Traversy Date: Tue, 11 Dec 2018 00:11:48 -0500 Subject: [PATCH 1/4] Adding error code because 'Code cannot be nil' If the app reaches this line it crashes because FlutterError asserts a non-null code. I'm reaching this line because I improperly formatted my function parameters, so I am naming the code "formattingError". The localized description should describe what exactly went wrong. --- packages/cloud_functions/ios/Classes/CloudFunctionsPlugin.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/cloud_functions/ios/Classes/CloudFunctionsPlugin.m b/packages/cloud_functions/ios/Classes/CloudFunctionsPlugin.m index 701c5efb3466..359d995ca393 100644 --- a/packages/cloud_functions/ios/Classes/CloudFunctionsPlugin.m +++ b/packages/cloud_functions/ios/Classes/CloudFunctionsPlugin.m @@ -56,7 +56,7 @@ - (void)handleMethodCall:(FlutterMethodCall *)call result:(FlutterResult)result message:@"Firebase function failed with exception." details:details]; } else { - flutterError = [FlutterError errorWithCode:nil + flutterError = [FlutterError errorWithCode:@"formattingError" message:error.localizedDescription details:nil]; } From 1fa379ce00b33ca53799042e0de0a61240acb9b2 Mon Sep 17 00:00:00 2001 From: Tim Traversy Date: Tue, 11 Dec 2018 00:39:16 -0500 Subject: [PATCH 2/4] changed to generic error --- packages/cloud_functions/ios/Classes/CloudFunctionsPlugin.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/cloud_functions/ios/Classes/CloudFunctionsPlugin.m b/packages/cloud_functions/ios/Classes/CloudFunctionsPlugin.m index 359d995ca393..380d5c8c751f 100644 --- a/packages/cloud_functions/ios/Classes/CloudFunctionsPlugin.m +++ b/packages/cloud_functions/ios/Classes/CloudFunctionsPlugin.m @@ -56,7 +56,7 @@ - (void)handleMethodCall:(FlutterMethodCall *)call result:(FlutterResult)result message:@"Firebase function failed with exception." details:details]; } else { - flutterError = [FlutterError errorWithCode:@"formattingError" + flutterError = [FlutterError errorWithCode:@"genericError" message:error.localizedDescription details:nil]; } From 7041b936949236136a42d8998ec3ce6b78f4d8d5 Mon Sep 17 00:00:00 2001 From: Collin Jackson Date: Fri, 14 Jun 2019 17:34:50 -0700 Subject: [PATCH 3/4] Bump for release --- packages/cloud_functions/CHANGELOG.md | 4 ++++ packages/cloud_functions/pubspec.yaml | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/cloud_functions/CHANGELOG.md b/packages/cloud_functions/CHANGELOG.md index e070431c0e9e..3c8b0fc1a48e 100644 --- a/packages/cloud_functions/CHANGELOG.md +++ b/packages/cloud_functions/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.0.5+1 + +* Fix crash due to use of null error code when encountering generic errors. + ## 0.0.5 * Set iOS deployment target to 8.0 (minimum supported by both Firebase SDKs and Flutter), fixes compilation errors. diff --git a/packages/cloud_functions/pubspec.yaml b/packages/cloud_functions/pubspec.yaml index 145ae0707d37..13e32fae4b3a 100644 --- a/packages/cloud_functions/pubspec.yaml +++ b/packages/cloud_functions/pubspec.yaml @@ -1,6 +1,6 @@ name: cloud_functions description: Flutter plugin for Cloud Functions. -version: 0.0.5 +version: 0.0.5+1 author: Flutter Team homepage: https://github.com/flutter/plugins/tree/master/packages/cloud_functions From 6c13a7d748fe2aff0b407da50bdee2484a0fce1d Mon Sep 17 00:00:00 2001 From: Collin Jackson Date: Fri, 14 Jun 2019 17:35:00 -0700 Subject: [PATCH 4/4] Implement Android side --- .../cloudfunctions/cloudfunctions/CloudFunctionsPlugin.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/cloud_functions/android/src/main/java/io/flutter/plugins/firebase/cloudfunctions/cloudfunctions/CloudFunctionsPlugin.java b/packages/cloud_functions/android/src/main/java/io/flutter/plugins/firebase/cloudfunctions/cloudfunctions/CloudFunctionsPlugin.java index 3de5a3d6ee0e..a0ed64f05406 100644 --- a/packages/cloud_functions/android/src/main/java/io/flutter/plugins/firebase/cloudfunctions/cloudfunctions/CloudFunctionsPlugin.java +++ b/packages/cloud_functions/android/src/main/java/io/flutter/plugins/firebase/cloudfunctions/cloudfunctions/CloudFunctionsPlugin.java @@ -57,7 +57,7 @@ public void onComplete(@NonNull Task task) { exceptionMap); } else { Exception exception = task.getException(); - result.error(null, exception.getMessage(), null); + result.error("genericError", exception.getMessage(), null); } } }