Implemented reading from struct fields

This commit is contained in:
Eduard Urbach 2025-02-04 20:43:15 +01:00
parent e36d9fade3
commit 71d7cdf5b2
Signed by: eduard
GPG key ID: 49226B848C78F6C8
10 changed files with 112 additions and 15 deletions

View file

@ -0,0 +1,19 @@
package errors
import "fmt"
// UnknownStructField represents unknown struct fields.
type UnknownStructField struct {
StructName string
FieldName string
CorrectFieldName string
}
// Error generates the string representation.
func (err *UnknownStructField) Error() string {
if err.CorrectFieldName != "" {
return fmt.Sprintf("Unknown struct field '%s' in '%s', did you mean '%s'?", err.FieldName, err.StructName, err.CorrectFieldName)
}
return fmt.Sprintf("Unknown struct field '%s' in '%s'", err.FieldName, err.StructName)
}