Colton Idle
05/27/2024, 7:26 PMSam
05/28/2024, 8:36 AMSam
05/28/2024, 8:38 AMSam
05/28/2024, 8:40 AMStylianos Gakis
05/28/2024, 8:57 AMColton Idle
05/29/2024, 6:13 PMwhen (val result = myApi.someEndpoint()) {
is Success -> doSomethingWith(result.response)
is Failure -> when (result) {
is NetworkFailure -> showError(result.error)
is HttpFailure -> showError(result.code)
is ApiFailure -> showError(result.error)
is UnknownFailure -> showError(result.error)
}
}
^ inspired by slack's eithernet library.
but man... just doing result.when then hitting alt + enter and getting all of the success and failure cases was so nice.