How can I create a Map (it that's the best way) of having something for instance :
400 to CustomExceptionFor400
500 to CustomExceptionFor500
The first param is an Int and it's a HttpStatusCode, and the value is something like this
sealed class OrganizationExceptions : Exception() {
object OrganizationNotFound : OrganizationExceptions()
object ListNotAvailable : OrganizationExceptions()
}
This is an example, but it won't be always "OrganizationExceptions" I'm creating a method generic, also I don't know if it's better to create a sealed class or create
class OrganizationNotFoundException : Throwable() //or Exception()
class ListNotAvailable : Throwable() //or Exception()
Any recomendations?
the method signature is :
fun apiCallWithStatusCode(codes : HashMap<Int, Throwable>, apiCall : suspend () -> Response<T>,){...}