Jokubas Alekna
07/21/2025, 3:46 PMphldavies
07/21/2025, 3:59 PMktor-arrow-example
shows this in a few places, i.e.:
return Either.catchOrThrow<PSQLException, UserId> {
usersQueries.create(salt, key, username, email)
}
.mapLeft { psqlException ->
if (psqlException.sqlState == PSQLState.UNIQUE_VIOLATION.state)
UsernameAlreadyExists(username)
else throw psqlException // <-- if we haven't handled the exception as a domain error, propagate it
}
Jokubas Alekna
07/21/2025, 4:02 PMYoussef Shoaib [MOD]
07/21/2025, 5:15 PMRaise
and contexts. There is an emerging philosophy though of letting exceptions be for truly exceptional situations. These best practices are basically us Arrow users realising that an exception should have been a domain error. This is a good pragmatic way to deal with it. In a way, we're building mini-wrappers for those libraries in our code.Jokubas Alekna
07/21/2025, 6:27 PM