3 ms·
>If it can result in an error and you don't handle that error, your program's behavior is undefined. Undefined behavior is a bad thing.™ There are way more adv
by coldtea 10y ago
>If it can result in an error and you don't handle that error, your program's behavior is undefined. Undefined behavior is a bad thing.™
There are way more advanced ways to handle errors than if err != nil boilerplate.
- mixedCase 10y agoSuch as? In before: Unchecked exceptions that I can forget about instead of always handling the errors gracefully or consciously pushing down the stack.
- coldtea 10y ago>Unchecked exceptions that I can forget about Not any more than you can forget about the returned error code in Go (val, _ := foo() etc). But with all the added convenience of exceptions. What you'd seem to describe, and which Go lacks, are Optionals that you have to handle for every option. And lots of other schemes (even Conditions).
- mixedCase 10y ago>Not any more than you can forget about the returned error code in Go (val, _ := foo() etc). I'm pretty sure that's an underscore right there, that very explicitly means "I'm consciously ignoring this error". Not sure what you're talking about with Optionals and Conditionals. Errors in Go are in the end structs that satisfy the error interface. That doesn't have to be an errors.Error, you can implement your own to satisfy more complex needs.