by absove · 4y ago · 0 comments
So to achieve the same exhaustiveness as a method like
User createUser() throws IOException, BusinessException
you would need both a Result-like construct and union types
Either<User, IOException | BusinessException> createuser()
which few mainstream languages offer. Otherwise you type is unable to express that only IOException and BusinessException are thrown and you don't need to handle a default Throwable case.
methods that declare checked exception can throw RuntimeException(s) so exhaustiveness cannot be totally enforced anyway