android-components / mozilla.components.service.fxa / handleFxaExceptions

handleFxaExceptions

suspend fun <T> handleFxaExceptions(logger: Logger, operation: String, block: suspend () -> T, postHandleAuthErrorBlock: (FxaUnauthorizedException) -> T, handleErrorBlock: (FxaException) -> T): T (source)

Runs a provided lambda, and if that throws non-panic, non-auth FxA exception, runs handleErrorBlock. If that lambda throws an FxA auth exception, notifies authErrorRegistry, and runs postHandleAuthErrorBlock.

Parameters

block - A lambda to execute which mail fail with an FxaException.

postHandleAuthErrorBlock - A lambda to execute if block failed with FxaUnauthorizedException.

handleErrorBlock - A lambda to execute if block fails with a non-panic, non-auth FxaException.

Return object of type T, as defined by block.

suspend fun <T> handleFxaExceptions(logger: Logger, operation: String, default: (FxaException) -> T, block: suspend () -> T): T (source)

Helper method that handles FxaException and allows specifying a lazy default value via default block for use in case of errors. Execution is wrapped in log statements.

suspend fun handleFxaExceptions(logger: Logger, operation: String, block: () -> Unit): Boolean (source)

Helper method that handles FxaException and returns a Boolean success flag as a result.