zio/zio-process

Consider adding an error ADT

reibitto opened this issue · 0 comments

This came up in the Discord. For context, I'm pasting my response:

I'm not against creating an error ADT for zio-process. There was no real opinionated reason for making it Throwable. The only real reason it's like that currently is because that's kind of the go-to default when wrapping Java libraries unless you dig deeper into the internals and map out all the ways it can fail. Sometimes that's easy enough to do... but other times it can be quite the task.

I agree that the way it is currently that Throwable is kind of exposing the fact that it's wrapping a Java library. That sort of feels like an implementation detail leaking out. If it were a library written 100% from scratch I wouldn't expect it to be Throwable.

I can understand the frustration with Throwable. Nobody wants to do control-flow logic on Throwable.getMessage (if the exceptions in the Java library aren't fine-grained enough) and so on.

So we would need to look into all the possible ways the Java lib can fail and design a reasonable ADT that captures those failures.