Hi,
I’m doing something like this:
kotlin.runCatching {
...
if(something())
throw NotAuthorizedException("Bad user.")
...
}.onFailure {
logger.error("User was bad.", it)
if (it is NotAuthorizedException)
return Result.failure(DepositAccountException.ClientErrorException("User was evil."))
}
Is this OK to do?
The definition of the Result.onFailure says it returns the original failure, but here I am overwriting that.
It seems to work fine, but I wanted to know if this was bad practice.