Skip to content

Instantly share code, notes, and snippets.

@cesarferreira
Created May 15, 2019 23:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save cesarferreira/955257d6722f2ab9245049ac463dfb70 to your computer and use it in GitHub Desktop.
Save cesarferreira/955257d6722f2ab9245049ac463dfb70 to your computer and use it in GitHub Desktop.
/**
* Base Class for handling errors/failures/exceptions.
* Every feature specific failure should extend [FeatureFailure] class.
*/
sealed class Failure(val exception: Exception = Exception("Failure")) {
object None : Failure()
object NetworkConnection : Failure()
object ServerError : Failure()
/** * Extend this class for feature specific failures.*/
open class FeatureFailure(featureException: Exception = Exception("Feature failure")) : Failure(featureException)
override fun equals(other: Any?): Boolean {
return other is Failure
}
}
@alaadeego
Copy link

if you could explain it's usage, please

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment