Skip to content

Instantly share code, notes, and snippets.

@ercnksgl
Last active September 20, 2022 12:47
Show Gist options
  • Save ercnksgl/5e0d3766426416db65152cd2ac04f062 to your computer and use it in GitHub Desktop.
Save ercnksgl/5e0d3766426416db65152cd2ac04f062 to your computer and use it in GitHub Desktop.
ApiError for sealed classes
import androidx.annotation.StringRes
import com.ercnksgl.sealedtest.R
sealed class ApiError {
data class ServerError(
val errorBody: String? = null
) : ApiError()
data class ConnectionError(
@StringRes val errorResId: Int = R.string.api_connection_error
) : ApiError()
data class UnexpectedError(
@StringRes val errorResId: Int = R.string.api_unexpected_error
) : ApiError()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment