package errors import ( "fmt" ) const ( ErrNotImplemented SimpleError = "not implemented" ErrUnexpectedStatus SimpleError = "unexpected status" ) type SimpleError string func (err SimpleError) Error() string { return string(err) } type ValidationError struct { Field string Reason string } func (err *ValidationError) Error() string { return fmt.Sprintf("field %s is not valid for reason %s", err.Field, err.Reason) } func NewValidationError(field, reason string) *ValidationError { if field == "" { panic("field not provided") } return &ValidationError{ Field: field, Reason: reason, } }