Skip to content

Commit

Permalink
Add examples to use the new recprdException overload
Browse files Browse the repository at this point in the history
  • Loading branch information
tejasd committed Nov 21, 2024
1 parent 9b6f346 commit 31af218
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,18 @@ public void logCaughtEx() {
// [END crash_log_caught_ex]
}

public void logCaughtExWithCustomKeys() {
// [START crash_log_caught_ex_custom_keys]
try {
methodThatThrows();
} catch (Exception e) {
FirebaseCrashlytics.getInstance()
.recordException(e, Map.of("key_1", "value_1", "key_2", "value_2"));
// handle your exception here
}
// [END crash_log_caught_ex_custom_keys]
}

public void forceACrash() {
// [START crash_force_crash]
Button crashButton = new Button(this);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,17 @@ class MainActivity : AppCompatActivity() {
// [END crash_log_caught_ex]
}

fun logCaughtExWithCustomKeys() {
// [START crash_log_caught_ex_custom_keys]
try {
methodThatThrows()
} catch (e: Exception) {
Firebase.crashlytics.recordException(e, mapOf("key_1" to "value_1", "key_2" to "value_2"))
// handle your exception here
}
// [END crash_log_caught_ex_custom_keys]
}

fun forceACrash() {
// [START crash_force_crash]
val crashButton = Button(this)
Expand Down

0 comments on commit 31af218

Please sign in to comment.