Make this error less fragile.
Having a nil pointer dereference cause a panic *during* error stringing
is really unpleasant.
We shouldn't "ever" have this problem, when the library is done.
But right no we certainly do.
@@ -14,5 +14,8 @@ type ErrNoSuchField struct {
}
func (e ErrNoSuchField) Error() string {
+ if e.Type == nil {
+ return fmt.Sprintf("no such field: {typeinfomissing}.%s", e.FieldName)
+ }
return fmt.Sprintf("no such field: %s.%s", e.Type.Name(), e.FieldName)
}
