3 ms·
Why do you believe errors are annotated by definition? They aren't? Panic isn't an ersatz error mechanism.
by preseinger 5y ago
Why do you believe errors are annotated by definition? They aren't?
Panic isn't an ersatz error mechanism.
- nkozyra 5y agoPedantry on my part, but annotated does not mean including a stack trace, simply that it includes a description of the error. Given it's a non-nil check, you never gave a guarantee it's valuable, but the error is itself at minimum an annotation. panic brings important context, but you're right in that it's not an annotation in itself. It's a program flow mechanism, but I'd argue it's very often utilized as an error flow one. My larger point was that this still doesn't feel like an "antipattern" and I see that word thrown around enough as a conversation stopper that I've become pretty cynical about it.
- preseinger 5y ago"Annotated" means given `err error`, you return `fmt.Errorf("annotation: %w", err)` — nothing more or less.