Skip to content

Instantly share code, notes, and snippets.

@LloydBlv
Created February 3, 2024 04:17
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 LloydBlv/5721668ce4e662ae8ee7583a263652a1 to your computer and use it in GitHub Desktop.
Save LloydBlv/5721668ce4e662ae8ee7583a263652a1 to your computer and use it in GitHub Desktop.
interface ErrorFormatter {
fun format(throwable: Throwable?) : StringResource
}
class ErrorFormatterDefault: ErrorFormatter {
override fun format(throwable: Throwable?) : StringResource {
return when (throwable) {
is SocketTimeoutException-> StringResource.ResId(R.string.not_connected_to_internet)
else -> StringResource.Text("Something went wrong!")
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment