3 ms·
But isn’t the actual advantage here that it gives me the ability to handle that error case specifically? I mean stuff like IO errors can happen everywhere at an
by 9dev 2y ago
But isn’t the actual advantage here that it gives me the ability to handle that error case specifically? I mean stuff like IO errors can happen everywhere at any time anyway, but if I need to do something specifically if there is no such element, isn’t that a plus? Otherwise, I’d have no chance to handle that error if I can do so.
- MBCook 2y agoHandling there is probably the right thing to do. I think the argument is that there is probably a better way of expressing that in code than exceptions. Perhaps returning an Either<Data, ErrorCode> kind of value. There’s also an argument that that’s not truly an exception because it should be expected that an I/O error is a reasonable possibility. Things like OutOfMemory or VirtualMachineError are more what they may be thinking exceptions should be saved for. Truly unexpected things.