3 ms·
> But what do you do when the libraries that you depend on throw exceptions instead of using Either? tome's response is amusing, but assuming you need to keep
by dllthomas 10y ago
> But what do you do when the libraries that you depend on throw exceptions instead of using Either?
tome's response is amusing, but assuming you need to keep getting work done and aren't interested in forking the library...
You wrap the library in a shim that forces the return values, catches anything that's thrown, and returns Either. If it's a library that you only use in one or two places, that shim might be inlined.
- dllthomas 10y agoI should note that, where you prefer to be dealing with exceptions, it's trivial to go the other way with a shim as well.