Re:Go Replaces Interface{} with 'Any'
by peoplefromibiza on Wednesday December 15, 2021 @08:00AM
(#29565331)
checked exceptions don't integrate very well with streams and reactive pipelines, to the point that basically all of then end up being wrapped and rethrown as unchecked
methods that declare checked exception can throw RuntimeException(s) so exhaustiveness cannot be totally enforced anyway
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.