3 ms·
Error handling is such a train wreck. Manually returning an error in 2021? What were they smoking?
by nprateem 6y ago
Error handling is such a train wreck. Manually returning an error in 2021? What were they smoking?
- it 6y agoIt's actually really nice to have the good quality error messages that Go encourages when something goes wrong.
- nprateem 6y agoIf you remember to write them and propagate them...
- jamiesonbecker 6y agoExplicit is better than implicit, and you can't get much more explicit than that.
- erik_seaberg 6y agoNobody wants to write or read PUSH EBP MOV EBP, ESP SUB ESP, 12 a thousand times a day. The best you can do is avoid screwing it up. So when you write a function in any language since 1960 it just happens. Stopping a function halfway and bubbling an error up the stack should also just happen.
- _peeley 6y agoI agree, although there are IMO more optimal and explicit ways to handle errors - Rust and Haskell come to mind. When dealing with a Result/Either/Maybe or some other functor, you have to acknowledge the context of the value, i.e. that the value could possibly be an error. This way the error handling is baked into the type system in a way that's hard to replicate in languages that just return error codes or exceptions.
- antonvs 6y ago> Explicit is better than implicit Which just demonstrates why slogans are not a good substitute for thought. They're good for programming a community though.
- nprateem 6y agoIf you believe that I hope you only write in assembler