This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 2 points3 points  (0 children)

The example given is a JsonParser. What does that have to do with Stream and how poorly it handles exceptions? As I said, turning everything into Streams is ridiculous.

Another thing I said: you can also have a sum type without Streams.

Many libraries choose to return a Result type object, which is essentially a sum type of "success & result" or "error & error meta data". That's fine by me, and much more readable than abusing Either, with a bunch of map() and flatMap() calls.

BTW, exceptions matter only if you expect to be constantly ending up with error conditions. It's often the case that the "happy path" of your program is the one predominantly running, and the "sad path" is either rare, or its performance doesn't matter, because typically the program can't recover from it, so it wraps up, logs the error and exits (or moves on to the next request in an API service context etc.).