Debian Codegraph @

v1/errors.go

raw
1 package client
2
3 import "encoding/json"
4
5 // SimpleError wraps simple error messages that come from
6 // the Enterprise API, such as:
7 // {"error":"json: cannot unmarshal number into Go value of type string"}
8 type SimpleError struct {
9 Message string `json:"error"`
10 }
11
12 func (se SimpleError) Error() string {
13 return se.Message
14 }
15
16 // ValidationErrors wraps more complex validation errors
17 // that the Enterprise API generates. These most usually come
18 // as the result of a 422 error.
19 type ValidationErrors struct {
20 Errors map[string][]string `json:"errors"`
21 }
22
23 func (ve ValidationErrors) Error() string {
24 b, _ := json.Marshal(ve)
25 return string(b)
26 }