Skip to content

Commit c42b173

Browse files
authored
fix(crashlytics): do not pass null to recordException(...) (#842)
1 parent 61a15cb commit c42b173

File tree

2 files changed

+13
-7
lines changed

2 files changed

+13
-7
lines changed

.changeset/thick-socks-fetch.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@capacitor-firebase/crashlytics': patch
3+
---
4+
5+
fix(android): do not pass `null` to `recordException(...)`

packages/crashlytics/android/src/main/java/io/capawesome/capacitorjs/plugins/firebase/crashlytics/FirebaseCrashlytics.java

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package io.capawesome.capacitorjs.plugins.firebase.crashlytics;
22

3+
import androidx.annotation.NonNull;
34
import androidx.annotation.Nullable;
45
import com.getcapacitor.JSArray;
56
import com.getcapacitor.PluginCall;
@@ -61,16 +62,16 @@ public void deleteUnsentReports() {
6162

6263
public void recordException(String message, JSArray stacktrace, @Nullable JSArray keysAndValues) {
6364
Throwable throwable = getJavaScriptException(message, stacktrace);
64-
CustomKeysAndValues customKeysAndValues = getCustomKeysAndValues(keysAndValues);
65-
getFirebaseCrashlyticsInstance().recordException(throwable, customKeysAndValues);
66-
}
67-
68-
@Nullable
69-
private CustomKeysAndValues getCustomKeysAndValues(@Nullable JSArray keysAndValues) {
7065
if (keysAndValues == null) {
71-
return null;
66+
getFirebaseCrashlyticsInstance().recordException(throwable);
67+
} else {
68+
CustomKeysAndValues customKeysAndValues = getCustomKeysAndValues(keysAndValues);
69+
getFirebaseCrashlyticsInstance().recordException(throwable, customKeysAndValues);
7270
}
71+
}
7372

73+
@NonNull
74+
private CustomKeysAndValues getCustomKeysAndValues(@NonNull JSArray keysAndValues) {
7475
CustomKeysAndValues.Builder builder = new CustomKeysAndValues.Builder();
7576
try {
7677
for (int i = 0; i < keysAndValues.length(); i++) {

0 commit comments

Comments
 (0)