Skip to content

Commit

Permalink
Add unsafe try-catch
Browse files Browse the repository at this point in the history
  • Loading branch information
meiron03 committed Feb 11, 2025
1 parent 78d8012 commit da997ea
Showing 1 changed file with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.pennapps.labs.pennmobile.api

import com.google.firebase.crashlytics.FirebaseCrashlytics
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
Expand All @@ -19,7 +20,14 @@ class OAuth2NetworkManager(
val result = networkManager.getAccessToken()
if (result is NetworkResult.Success) {
withContext(Dispatchers.Main) {
function.invoke(result.data)
// NOTE: This is actually quite dangerous because the coroutine is not
// lifecycle aware. There is a reason why this is being deprecated.
try {
function.invoke(result.data)
} catch (e: Exception) {
FirebaseCrashlytics.getInstance().recordException(e)
e.printStackTrace()
}
}
}
}
Expand Down

0 comments on commit da997ea

Please sign in to comment.