Skip to content

Instantly share code, notes, and snippets.

@raamcosta
Last active November 28, 2021 22:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save raamcosta/b8aaa20fba92c3f5a0ee8c0af7143b14 to your computer and use it in GitHub Desktop.
Save raamcosta/b8aaa20fba92c3f5a0ee8c0af7143b14 to your computer and use it in GitHub Desktop.
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