Skip to content

Commit

Permalink
feat: better error messages
Browse files Browse the repository at this point in the history
  • Loading branch information
Oudwins committed Sep 16, 2024
1 parent 6b578e9 commit f161023
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion struct.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package zog

import (
"errors"
"fmt"
"maps"
"reflect"
"strings"
Expand Down Expand Up @@ -137,9 +138,13 @@ func (v *structProcessor) process(data any, dest any, path p.PathBuilder, ctx p.
for key, processor := range v.schema {
fieldKey := key
key = strings.ToUpper(string(key[0])) + key[1:]

fieldMeta, ok := structVal.Type().FieldByName(key)
if !ok {
panic(fmt.Sprintf("Struct is missing expected schema key: %s", key))
}
destPtr := structVal.FieldByName(key).Addr().Interface()

fieldMeta, _ := structVal.Type().FieldByName(key)
fieldTag, ok := fieldMeta.Tag.Lookup(p.ZogTag)
if ok {
fieldKey = fieldTag
Expand Down

0 comments on commit f161023

Please sign in to comment.