5 ms·
That's not what I meant. Code that handles an error looks like this: if err! = nil { if fileErr,ok := err.(MissingFileError); ok { crea
by tsimionescu 7y ago
That'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.