-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
AND-8882 Updated stakekit errors (#3616)
- Loading branch information
Showing
18 changed files
with
275 additions
and
589 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 19 additions & 2 deletions
21
data/staking/src/main/java/com/tangem/data/staking/DefaultStakingErrorResolver.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,36 @@ | ||
package com.tangem.data.staking | ||
|
||
import com.tangem.core.analytics.api.AnalyticsEventHandler | ||
import com.tangem.data.staking.converters.error.StakeKitErrorConverter | ||
import com.tangem.datasource.api.common.response.ApiResponseError | ||
import com.tangem.domain.staking.analytics.StakingAnalyticsEvent | ||
import com.tangem.domain.staking.model.stakekit.StakingError | ||
import com.tangem.domain.staking.repositories.StakingErrorResolver | ||
|
||
internal class DefaultStakingErrorResolver( | ||
private val analyticsEventHandler: AnalyticsEventHandler, | ||
private val stakeKitErrorConverter: StakeKitErrorConverter, | ||
) : StakingErrorResolver { | ||
|
||
override fun resolve(throwable: Throwable): StakingError { | ||
return if (throwable is ApiResponseError.HttpException) { | ||
val error = if (throwable is ApiResponseError.HttpException) { | ||
stakeKitErrorConverter.convert(throwable.errorBody.orEmpty()) | ||
} else { | ||
StakingError.UnknownError() | ||
StakingError.DomainError(throwable.message) | ||
} | ||
|
||
when (error) { | ||
is StakingError.StakeKitApiError -> { | ||
analyticsEventHandler.send(StakingAnalyticsEvent.StakeKitApiError(error)) | ||
} | ||
is StakingError.StakeKitUnknownError -> { | ||
analyticsEventHandler.send(StakingAnalyticsEvent.StakeKitApiUnknownError(error)) | ||
} | ||
else -> { | ||
// intentionally do nothing | ||
} | ||
} | ||
|
||
return error | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.