top | item 18538559

(no title)

wild_preference | 7 years ago

No, the alternative here would be to just let the write()'s throw and let upstream handle them. You don't try/catch to catch an error just to re-throw it for the same reason you don't try/catch every single line of your program.

Exceptions are one reason other languages don't need this "if err throw err" code, without making a comment on if either is superior.

discuss

order

bouncycastle|7 years ago

Yeah, but an error error is not really an exception. Often in Go, errors are used to mark different states, such as EOF which are expected and you can deal with locally and have more control whenever you want to return or not, for example, you can test the error in the same if condition and decide whenever to keep going - usually you do. Error handling code is more local rather than all over the place, plus no need to declare more classes for specific exceptions.

dymk|7 years ago

> Often in Go, errors are used to mark different states, such as EOF which are expected

Then it's not an error, and Go has once again forced people into writing something semantically confusing and/or incorrect because it lacks basic abstractions.