Re:How can C Programs be so Reliable? (2008)
by flogic on Thursday December 05, 2013 @10:20PM
(#6859171)
I disagree. Go errors aren't even error codes. The error interface is just one method that returns a string. The only advantage Go has over C is that the errors are no longer inband with normal return values. Once you get one though, you're back in the perl5 land of reasoning about your error by scraping a string. I'm completely baffled as to why they didn't attempt to bundle more machine readable information into the errors.
Re:How can C Programs be so Reliable? (2008)
by mfenniak on Thursday December 05, 2013 @10:35PM
(#6859231)
Go errors are machine-readable data.
Most modules expose variables with the naming convention Err... that represent the errors that they can return. The errors can be compared with those values (eg. err == os.ErrPermission). Some modules also define error types that provide additional error data, such as net.OpError; a type-cast can be used to check if the error is of that type, and then access the data within. As a fallback, all errors implement the Error interface which allows you to display them as a string if you can't handle them based upon their type.
It's not unlike exception handling by exception type, although it's definitely more of a manual process because Go doesn't give you specialized syntax for it.
Go being a glaring exception -- and this is a good thing.