Repository navigation
Expand file tree
/
Copy patherrors.go
More file actions
67 lines (54 loc) · 1.91 KB
/
Copy patherrors.go
File metadata and controls
67 lines (54 loc) · 1.91 KB
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
package chartquery
import "fmt"
// ConfigurationError reports a missing or unusable client configuration.
type ConfigurationError struct {
Message string
Err error
}
func (e *ConfigurationError) Error() string { return e.Message }
func (e *ConfigurationError) Unwrap() error { return e.Err }
// SerializationError reports a parameter that is missing or cannot be sent.
type SerializationError struct {
Param string
Message string
Err error
}
func (e *SerializationError) Error() string { return e.Message }
func (e *SerializationError) Unwrap() error { return e.Err }
// TransportError reports a failure before a complete HTTP response was received,
// including client-side timeouts and context cancellation (see Unwrap).
type TransportError struct {
Message string
Err error
}
func (e *TransportError) Error() string { return e.Message + ": " + e.Err.Error() }
func (e *TransportError) Unwrap() error { return e.Err }
// APIError is returned for non-2xx responses.
type APIError struct {
StatusCode int
// Message is the "error" (or "message") field of the JSON body, when present.
Message string
Response *Response
}
func (e *APIError) Error() string {
if e.Message != "" {
return fmt.Sprintf("ChartQuery API error %d: %s", e.StatusCode, e.Message)
}
return fmt.Sprintf("ChartQuery API request failed with status %d.", e.StatusCode)
}
// ResponseDecodingError reports a success response that could not be decoded.
type ResponseDecodingError struct {
Message string
Response *Response
Err error
}
func (e *ResponseDecodingError) Error() string { return e.Message }
func (e *ResponseDecodingError) Unwrap() error { return e.Err }
// JobTimeoutError reports an async job that did not finish before the deadline.
type JobTimeoutError struct {
JobID string
LastResponse *Response
}
func (e *JobTimeoutError) Error() string {
return "Job " + e.JobID + " did not finish before the deadline."
}