Skip to content

Commit

Permalink
Merge pull request #26 from segmentio/helpful-error
Browse files Browse the repository at this point in the history
load: clarify some error messages
  • Loading branch information
abraithwaite authored Jul 18, 2018
2 parents cee1e55 + 9c04b53 commit a2a7fb2
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions load.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,15 +109,15 @@ func (ld Loader) Load(cfg interface{}) (cmd string, args []string, err error) {
}

if v.Kind() != reflect.Ptr {
panic(fmt.Sprintf("cannot load configuration into %T", cfg))
panic(fmt.Sprintf("cannot load configuration into non-pointer type: %T", cfg))
}

if v.IsNil() {
panic(fmt.Sprintf("cannot load configuration into nil %T", cfg))
panic(fmt.Sprintf("cannot load configuration into nil pointer of type: %T", cfg))
}

if v = v.Elem(); v.Kind() != reflect.Struct {
panic(fmt.Sprintf("cannot load configuration into %T", cfg))
panic(fmt.Sprintf("cannot load configuration into non-struct pointer: %T", cfg))
}

if len(ld.Commands) != 0 {
Expand Down

0 comments on commit a2a7fb2

Please sign in to comment.