5 ms·
I love the error handling in Go. Every other language I've used led to the inevitable and useless "An error was encountered" message. Go is the first language
by Xeoncross 9y ago
I love the error handling in Go. Every other language I've used led to the inevitable and useless "An error was encountered" message.
Go is the first language where I can actually access the original socket permission error because it was actually passed up.
- thesmallestcat 9y agoYou just described exceptions.
- wyager 9y ago> Every other language I've used led to the inevitable and useless "An error was encountered" message. I can't think of a single language except C where this has been a problem for me. What are you referring to?
- KirinDave 9y agoWhat's weird is that what they're describing is actually really tricky to do reliably in Go unless you totally understand every library beneath you. Much bad can be said about checked exceptions, but they certainly helped with that problem...
- camus2 9y ago> Go is the first language where I can actually access the original socket permission error because it was actually passed up. Now try to trace them as easily as exceptions. Oh wait, you can't unless you wrap Go errors into some struct from a library that isn't in the std lib therefore everybody has different systems to trace errors /s i'll take exceptions over this (which go has, panic/defer). error is just a convention, it's not an error system.
- KirinDave 9y agoI'll take Either where I can guarantee I know what I'm dealing with and that it's dealt with rather than the honors system Go offers.
- concede_pluto 9y agoGo is basically using multiple return values as a half baked Either type, only you're on your own if you want to pass it over a channel or store it anywhere.
- KirinDave 9y agoSadly go can't even half bake a sum type suitable for this work without generics.
- lobster_johnson 9y agoPretty much every language has this: Java, Python, Ruby, Haskell, OCaml, C++... The only major language that I can think of that doesn't have a standard error propagation mechanism is C.
- Xeoncross 9y agoHave is different from use, in practice. I should say that In the real world Go libs actually pass the errors up while my experience with other languages has been shaking my head at the useless errors that I get back from the libs.
- KirinDave 9y agoWell I won't deny you this experience, but I do think maybe you've been lucky in which parts of the stdlib you've worked in. Because I felt nothing but frustration at most libs I worked with. I (as others before me) ended up grepping error strings.