-
Notifications
You must be signed in to change notification settings - Fork 12
Open
Description
I have been using this library for quite a while, and I can't recall one place where I didn't use Exceptions.sneak()#method.
Consider this example:
List<Path> nonEmptyFiles = Files.list(somePath)
.filter(path -> Exceptions.sneak().get(() -> Files.readString(path)).isEmpty())
.toList();The filter is ugly and takes too much time to understand for its purpose.
My suggestion is to allow users to choose their preferred ExceptionHandler - so 99% of the time the syntax is clearer and shorter:
.filter(path -> Unchecked.get(() -> Files.readString(path)).isEmpty())
P.S: I know the example can be rewritten using map/filter, but it still feels like too much...
.map(Exceptions.sneak().function(Files::readString))
.filter(not(String::isEmpty)Metadata
Metadata
Assignees
Labels
No labels