File: errors.go

package info (click to toggle)
golang-github-influxdb-usage-client 0.0~git20151204.0.475977e-5
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 152 kB
  • sloc: makefile: 2
file content (26 lines) | stat: -rw-r--r-- 635 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
package client

import "encoding/json"

// SimpleError wraps simple error messages that come from
// the Usage API, such as:
// {"error":"json: cannot unmarshal number into Go value of type string"}
type SimpleError struct {
	Message string `json:"error"`
}

func (se SimpleError) Error() string {
	return se.Message
}

// ValidationErrors wraps more complex validation errors
// that the Usage API generates. These most usually come
// as the result of a 422 error.
type ValidationErrors struct {
	Errors map[string][]string `json:"errors"`
}

func (ve ValidationErrors) Error() string {
	b, _ := json.Marshal(ve)
	return string(b)
}