Currently any errors which come back from the VES API are unmarshalled into the following struct:
type ErrorResponse struct {
Errors []Error `json:"errors"`
}
type Error struct {
Status Status `json:"status,omitempty"`
Code Status `json:"code,omitempty"`
Title string `json:"title"`
Detail string `json:"detail,omitempty"`
}
Unfortunately the VES API isn't so consistent. When Supplying the following test registration number ER19THR as documented in the Test API response document it is supposed to return a 429 Too Many Requests
What it actually returns:
{
"message": "Too Many Requests"
}
This obviously fails to unMarshal into the ErrorResponse type and actually causes a nil pointer exception when the array is nil in func Do as shown below:
func (r *Request) Do(v interface{}) (*http.Response, error) {
if r.e != nil {
return nil, r.e
}
resp, err := r.c.httpClient.Do(r.Request)
if err != nil {
return nil, err
}
defer resp.Body.Close()
if resp.StatusCode != 200 {
var errResp ErrorResponse
err := json.NewDecoder(resp.Body).Decode(&errResp)
if err != nil {
return resp, err
}
return resp, errResp.Errors[0]
}
I suggest creating a custom unmarshalling function for ErrorResponse which accounts for the VES API's inconsistencies.
Will make a PR when we get around to fixing it on our end if you don't fix it before us.
Currently any errors which come back from the VES API are unmarshalled into the following struct:
Unfortunately the VES API isn't so consistent. When Supplying the following test registration number
ER19THRas documented in the Test API response document it is supposed to return a429 Too Many RequestsWhat it actually returns:
This obviously fails to unMarshal into the
ErrorResponsetype and actually causes a nil pointer exception when the array isnilinfunc Doas shown below:I suggest creating a custom unmarshalling function for
ErrorResponsewhich accounts for the VES API's inconsistencies.Will make a PR when we get around to fixing it on our end if you don't fix it before us.