Skip to content

Commit

Permalink
More descriptive error when unmarshaling ID/Time
Browse files Browse the repository at this point in the history
This adds a tiny bit more information to the error messages produced
when unmarshaling an input value to an ID or Time fails.
  • Loading branch information
mrnugget committed Jun 30, 2020
1 parent c1d9693 commit 90e03d2
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions id.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package graphql

import (
"errors"
"fmt"
"strconv"
)

Expand All @@ -20,7 +20,7 @@ func (id *ID) UnmarshalGraphQL(input interface{}) error {
case int32:
*id = ID(strconv.Itoa(int(input)))
default:
err = errors.New("wrong type")
err = fmt.Errorf("wrong type for ID: %T", input)
}
return err
}
Expand Down
2 changes: 1 addition & 1 deletion time.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func (t *Time) UnmarshalGraphQL(input interface{}) error {
t.Time = time.Unix(int64(input), 0)
return nil
default:
return fmt.Errorf("wrong type")
return fmt.Errorf("wrong type for Time: %T", input)
}
}

Expand Down

0 comments on commit 90e03d2

Please sign in to comment.