Change if/if to if/else-if when checking the type of JSON error

This commit is contained in:
Herman Slatman 2022-01-12 21:34:38 +01:00
parent a3cf6bac36
commit 50c3bce98d
No known key found for this signature in database
GPG key ID: F4D8A44EA0A75A4F

View file

@ -573,8 +573,7 @@ func templatingError(err error) error {
if errors.As(err, &syntaxError) { if errors.As(err, &syntaxError) {
// offset is arguably not super clear to the user, but it's the best we can do here // offset is arguably not super clear to the user, but it's the best we can do here
cause = fmt.Errorf("%s at offset %d", cause.Error(), syntaxError.Offset) cause = fmt.Errorf("%s at offset %d", cause.Error(), syntaxError.Offset)
} } else if errors.As(err, &typeError) {
if errors.As(err, &typeError) {
// slightly rewriting the default error message to include the offset // slightly rewriting the default error message to include the offset
cause = fmt.Errorf("cannot unmarshal %s at offset %d into Go value of type %s", typeError.Value, typeError.Offset, typeError.Type) cause = fmt.Errorf("cannot unmarshal %s at offset %d into Go value of type %s", typeError.Value, typeError.Offset, typeError.Type)
} }