durian icon indicating copy to clipboard operation
durian copied to clipboard

Consider generalizing Errors so that it also works for more constrained throwers

Open oliviercailloux opened this issue 5 years ago • 3 comments

Unless I missed something, Errors currently is used to wrap all throwables. It would be useful to be able to use Errors (or a generalized version of it, say, SpecificErrors) to wrap interfaces which throw only one checked exception, for example, IOException. Thus, SpecificErrors would be a generic type, with a type parameter <E> which designates the kind of throwable to be wrapped. Any other unchecked exception thrown by the wrappers created by SpecificErrors would be left alone and thrown as-is.

oliviercailloux avatar May 15 '20 22:05 oliviercailloux

It's been a long time, but I have a hazy memory that template type inference didn't work like I expected when I tried it. Would be happy to look at a PR which explores this. I'm very busy atm, can't promise a fast turnaround time.

nedtwigg avatar May 16 '20 04:05 nedtwigg

Related to this issue and #8, I’d like to mention that I just released a few classes, inspired by durian’s “error” classes, which implement what I was thinking about (more strictly typed, with no duplication of Guava, and IMHO slightly simpler to use and understand).

Any comments would be much appreciated.

https://github.com/oliviercailloux/JARiS

oliviercailloux avatar Aug 28 '20 09:08 oliviercailloux

Congratulations! Looks like this issue is resolved, but I'll keep it open indefinitely to advertise your project. For now I still don't understand the need for SpecificErrors, but the great thing about open source is that you don't need convince me :D

nedtwigg avatar Aug 28 '20 17:08 nedtwigg