Last active
April 13, 2020 12:34
-
-
Save douglasiacovelli/d7d9a7cc3e0dd20ec81783607d044ff9 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 ResultWrapper<out T> { | |
| data class Success<out T>(val value: T): ResultWrapper<T>() | |
| data class GenericError(val code: Int? = null, val error: ErrorResponse? = null): ResultWrapper<Nothing>() | |
| object NetworkError: ResultWrapper<Nothing>() | |
| } |
Author
ErrorResponse is just a data class meant to map the errors the backend may
return if any occur.
For example, if the user sends a form with invalid data, the API could
return an error in this format detailing which field was wrong. This way
you can show a friendly and specific message to the user.
*Douglas Iacovelli*
Em dom., 12 de abr. de 2020 às 08:59, shamshadpattani <
[email protected]> escreveu:
… ***@***.**** commented on this gist.
------------------------------
what is ErrorResponse?
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<https://gist.github.com/d7d9a7cc3e0dd20ec81783607d044ff9#gistcomment-3251147>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAMIW5CTVO7HRNGCIMFADULRMGUKNANCNFSM4MGMKAOA>
.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
what is ErrorResponse?