-
Notifications
You must be signed in to change notification settings - Fork 0
/
errors.go
48 lines (38 loc) · 878 Bytes
/
errors.go
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
package prom
import "fmt"
type ClientError struct {
Code int
Body string
}
func (e *ClientError) Error() string {
return fmt.Sprintf("Error when request PROM (Code: %d, Body: %s)", e.Code, e.Body)
}
type RequestError struct {
reqType string
originErr error
}
func NewRequestError(t string, err error) *RequestError {
return &RequestError{
reqType: t,
originErr: err,
}
}
func (e *RequestError) Error() string {
return fmt.Sprintf("Error request %s: %s", e.reqType, e.originErr)
}
func (e *RequestError) GetOriginError() error {
return e.originErr
}
type ResponseError struct {
reqType string
originErr string
}
func NewResponseError(t string, e string) *ResponseError {
return &ResponseError{
reqType: t,
originErr: e,
}
}
func (e *ResponseError) Error() string {
return fmt.Sprintf("Error when request %s: %s", e.reqType, e.originErr)
}