-
-
Save raamcosta/b8aaa20fba92c3f5a0ee8c0af7143b14 to your computer and use it in GitHub Desktop.
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
sealed class GetMagicCardUseCaseError { | |
object InvalidCardNameFormat : GetMagicCardUseCaseError() | |
sealed class ApiCallError : GetMagicCardUseCaseError() { | |
class HttpUnsuccessfulCodeError(val httpCode: Int) : ApiCallError() | |
object RemoteServerNotReachedError : ApiCallError() | |
object UnexpectedApiCommunicationError : ApiCallError() | |
} | |
} | |
// Then handling one error would mean: | |
fun handleGetMagicCardUseCaseError(error: GetMagicCardUseCaseError) { | |
when (error) { | |
is GetMagicCardUseCaseError.ApiCallError.HttpUnsuccessfulCodeError -> //TODO | |
is GetMagicCardUseCaseError.ApiCallError.RemoteServerNotReachedError -> //TODO | |
is GetMagicCardUseCaseError.ApiCallError.UnexpectedApiCommunicationError -> //TODO | |
is GetMagicCardUseCaseError.InvalidCardNameFormat -> //TODO | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment