3 ms·
This is actually really interesting to me. I use C# for side projects and often write Debug.Assert everywhere to check things, but can't quite bring myself to t
by hacker_9 10y ago
This is actually really interesting to me. I use C# for side projects and often write Debug.Assert everywhere to check things, but can't quite bring myself to throw exceptions for full blown errors. I just find they add a lot of bloat, and don't really help the problem, they are just a lazy catch all. But I have to say returning Error<TResult> is a really elegant way of dealing with the problem, I think I will have to start doing it this way.
- barrkel 10y agoReturning an error type, and, in the caller, propagating that return type further up, is isomorphic to exceptions, except it's a lot more busywork, a lot more code bloat, and a lot easier to get wrong.
- perspectivep 10y agoAnd you have to remember to log the error at every level of the stack, otherwise you're left with an error code that has no context.
- yoklov 10y agoIt's also encoded in the return type of the function, so you get static type checking -- a property not present for exceptions.
- barrkel 10y agoYou say that like it's desirable. I think Java's experience of checked exceptions shows that it's of very dubious benefit.