Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Don't send a Sentry when we have an access_denied APIErrorException #2085

Merged
merged 1 commit into from
Nov 22, 2024
Merged
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
1 change: 1 addition & 0 deletions app/src/main/java/com/infomaniak/mail/utils/ErrorCode.kt
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ object ErrorCode {

//region Mailbox
const val MAILBOX_LOCKED = "mailbox_locked"
const val ACCESS_DENIED = "access_denied"
const val ERROR_WHILE_LINKING_MAILBOX = "error_while_linking_mailbox"
const val INVALID_MAILBOX_PASSWORD = "invalid_mailbox_password"
//endregion
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,14 @@ class FetchMessagesManager @Inject constructor(

private lateinit var coroutineScope: CoroutineScope

private fun shouldLogToSentry(throwable: Throwable?): Boolean {
return when (throwable) {
is CancellationException, is NetworkException -> false
is ApiErrorException -> throwable.errorCode != ErrorCode.ACCESS_DENIED
else -> true
}
}

// We can arrive here for Mailboxes we did not open yet. That's why we check before doing anything.
suspend fun execute(
scope: CoroutineScope,
Expand Down Expand Up @@ -96,7 +104,7 @@ class FetchMessagesManager @Inject constructor(
).let { (threads, throwable) ->

if (threads == null) {
if (throwable !is CancellationException && throwable !is NetworkException) {
if (shouldLogToSentry(throwable)) {
SentryDebug.sendFailedNotification(
reason = "RefreshThreads failed",
sentryLevel = SentryLevel.ERROR,
Expand Down
Loading