Typed error
A struct that implements error and carries fields, such as ValidationError{Field, Reason}. Callers extract it from a wrapped chain with errors.As, passing a pointer to a variable of the same type the Error method is defined on.
Minimal example
var ve *ValidationError
if errors.As(err, &ve) {
log.Println(ve.Field, ve.Reason)
}Learn this concept
Lesson 2.13 · Error classification in GoUsed in exercises
Exercise 2.14 · POST /v1/menu/price: price a configured itemPrerequisite conceptsError wrapping
RelatedSentinel error