Skip to content

Commit 90e03d2

Browse files
committed
More descriptive error when unmarshaling ID/Time
This adds a tiny bit more information to the error messages produced when unmarshaling an input value to an ID or Time fails.
1 parent c1d9693 commit 90e03d2

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

id.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package graphql
22

33
import (
4-
"errors"
4+
"fmt"
55
"strconv"
66
)
77

@@ -20,7 +20,7 @@ func (id *ID) UnmarshalGraphQL(input interface{}) error {
2020
case int32:
2121
*id = ID(strconv.Itoa(int(input)))
2222
default:
23-
err = errors.New("wrong type")
23+
err = fmt.Errorf("wrong type for ID: %T", input)
2424
}
2525
return err
2626
}

time.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ func (t *Time) UnmarshalGraphQL(input interface{}) error {
4141
t.Time = time.Unix(int64(input), 0)
4242
return nil
4343
default:
44-
return fmt.Errorf("wrong type")
44+
return fmt.Errorf("wrong type for Time: %T", input)
4545
}
4646
}
4747

0 commit comments

Comments
 (0)