Last active
October 20, 2018 03:58
-
-
Save timusus/c93e1c4712d2cba08569cbb2e5316ff4 to your computer and use it in GitHub Desktop.
Error to user description
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
fun Error.userDescription(): String { | |
return when (this) { | |
is RemoteServiceHttpError -> | |
return when { | |
isServerError -> "A server error occurred. (${httpStatusCode.code})" | |
else -> "An error occurred. (${httpStatusCode.code})" | |
} | |
} | |
is OAuthError -> { | |
return "Authentication failed." | |
} | |
is NetworkError -> { | |
return "The server could not be reached. Please check your connection and try again." | |
} | |
is UnexpectedError -> { | |
return "An unexpected error occurred." | |
} | |
else -> { | |
return "An unknown error occurred." | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment