refactor(errors): унифицировал доменные ошибки и добавил failed-статус задач
This commit is contained in:
@@ -6,6 +6,7 @@ import androidx.activity.result.ActivityResultLauncher
|
||||
import com.github.nullptroma.wallenc.domain.vault.vaults.yandex.YandexRegistration
|
||||
import com.github.nullptroma.wallenc.vault.contract.CloudBrand
|
||||
import com.github.nullptroma.wallenc.vault.contract.RemoteVaultAuthenticator
|
||||
import com.github.nullptroma.wallenc.vault.contract.VaultLinkFailure
|
||||
import com.github.nullptroma.wallenc.vault.contract.VaultLinkOutcome
|
||||
import com.yandex.authsdk.YandexAuthLoginOptions
|
||||
import com.yandex.authsdk.YandexAuthOptions
|
||||
@@ -70,16 +71,12 @@ class YandexSignInService @Inject constructor(
|
||||
|
||||
override fun beginLink(brand: CloudBrand, onResult: (VaultLinkOutcome) -> Unit) {
|
||||
if (brand != CloudBrand.YANDEX) {
|
||||
onResult(VaultLinkOutcome.Failed("Brand $brand is not supported by YandexSignInService"))
|
||||
onResult(VaultLinkOutcome.Failed(VaultLinkFailure.UnsupportedBrand))
|
||||
return
|
||||
}
|
||||
val l = launcher
|
||||
if (l == null) {
|
||||
onResult(
|
||||
VaultLinkOutcome.Failed(
|
||||
"YandexSignInService: call registerWith(activity) from MainActivity.onCreate first",
|
||||
),
|
||||
)
|
||||
onResult(VaultLinkOutcome.Failed(VaultLinkFailure.NotRegistered))
|
||||
return
|
||||
}
|
||||
synchronized(this) { pending = onResult }
|
||||
@@ -90,9 +87,7 @@ class YandexSignInService @Inject constructor(
|
||||
is YandexAuthResult.Success ->
|
||||
VaultLinkOutcome.Success(YandexRegistration(result.token.value))
|
||||
is YandexAuthResult.Failure ->
|
||||
VaultLinkOutcome.Failed(
|
||||
result.exception.message ?: result.exception.toString(),
|
||||
)
|
||||
VaultLinkOutcome.Failed(VaultLinkFailure.AuthError)
|
||||
YandexAuthResult.Cancelled -> VaultLinkOutcome.Cancelled
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user