4 ms·
> You're also making it much harder to tell the code that handles errors apart from the code which doesn't. Error handling isn't distinct from, or less interes
by sagichmal 7y ago
> You're also making it much harder to tell the code that handles errors apart from the code which doesn't.
Error handling isn't distinct from, or less interesting than, the principal logic of a block of code. Error handling is frequently the most important part of a block of code, especially in the domains that Go targets.
- tsimionescu 7y agoThat's not what I meant. Code that handles an error looks like this: if err! = nil { if fileErr,ok := err.(MissingFileError); ok { createFile(fileErr.FileName()) } else { return fmt.Errorf(...) } } While code that does NOT handle an error looks like this: if err!=nil { return fmt.Errorf(...) }
- stouset 7y agoAnd the former is less than 1% of the cases I’ve seen from experience. Somehow people have fooled themselves into believing that the language forcing humans to be manual exception bubblers somehow means they have “handled” the error.