Updated on 2026-08-14

This commit is contained in:
Tangem 2025-03-28 12:03:09 +03:00
parent 80d4eeaed9
commit 375afeea12
8 changed files with 78 additions and 0 deletions

1
core/error/.gitignore vendored Normal file
View file

@ -0,0 +1 @@
/build

View file

@ -0,0 +1,14 @@
plugins {
alias(deps.plugins.android.library)
alias(deps.plugins.kotlin.android)
id("configuration")
}
android {
namespace = "com.tangem.core.error"
}
dependencies {
implementation(tangemDeps.card.core)
implementation(tangemDeps.blockchain)
}

View file

@ -0,0 +1,23 @@
package com.tangem.core.error
/**
* Universal error interface for all errors in the app.
* Each error code must follow this format: xxxyyyzzz where
* xxx - Feature code
* yyy - Subsystem code
* zzz - Specific error code
* If you need to add new feature add it to list below incrementing last code.
*
* Features:
* `100` - App error
* `101` - TangemSdkError
* `102` - BlockchainSdkError
* `103` - Express
* `104` - Visa
* `105` - Staking
* `106` - NFT
* `107` - WalletConnect
*/
interface UniversalError {
val errorCode: Int
}

View file

@ -0,0 +1,14 @@
package com.tangem.core.error
import com.tangem.common.core.TangemSdkError
import com.tangem.blockchain.common.BlockchainSdkError
val TangemSdkError.universalError: UniversalError
get() = object : UniversalError {
override val errorCode: Int = 101000000 + code
}
val BlockchainSdkError.universalError: UniversalError
get() = object : UniversalError {
override val errorCode: Int = 102000000 + code
}

View file

@ -17,6 +17,7 @@ dependencies {
implementation(projects.core.res)
implementation(projects.core.utils)
implementation(projects.core.decompose)
implementation(projects.core.error)
/** AndroidX libraries */
implementation(deps.androidx.fragment.ktx)

View file

@ -1,8 +1,10 @@
package com.tangem.core.ui.message.dialog
import com.tangem.core.error.UniversalError
import com.tangem.core.ui.R
import com.tangem.core.ui.extensions.TextReference
import com.tangem.core.ui.extensions.resourceReference
import com.tangem.core.ui.extensions.wrappedList
import com.tangem.core.ui.message.DialogMessage
import com.tangem.core.ui.message.EventMessageAction
@ -36,4 +38,17 @@ object Dialogs {
secondActionBuilder = { cancelAction(onClick = onCancelClick) },
)
}
/**
* Universal error dialog
*/
fun universalErrorDialog(universalError: UniversalError, onOkClick: () -> Unit): DialogMessage {
return DialogMessage(
message = resourceReference(R.string.universal_error, wrappedList(universalError.errorCode)),
firstAction = EventMessageAction(
title = resourceReference(R.string.common_ok),
onClick = onOkClick,
),
)
}
}

View file

@ -0,0 +1,9 @@
package com.tangem.core.ui.utils
import com.tangem.core.decompose.ui.UiMessageSender
import com.tangem.core.error.UniversalError
import com.tangem.core.ui.message.dialog.Dialogs
fun UiMessageSender.showErrorDialog(universalError: UniversalError) {
send(Dialogs.universalErrorDialog(universalError) {})
}

View file

@ -148,6 +148,7 @@ include(":core:deep-links")
include(":core:deep-links:global")
include(":core:decompose")
include(":core:pagination")
include(":core:error")
// endregion Core modules
// region Common modules