-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patherrors.go
52 lines (41 loc) · 1.35 KB
/
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
49
50
51
52
package rapi
import "fmt"
// InvalidContentTypeError occurs when the request or response body content type is invalid.
type InvalidContentTypeError struct {
error error
contentType string
}
// Error is the implementation of error.
func (e *InvalidContentTypeError) Error() string {
return fmt.Errorf("invalid content type %q: %w", e.contentType, e.error).Error()
}
// Unwrap unwraps the underlying error.
func (e *InvalidContentTypeError) Unwrap() error {
return e.error
}
// ContentType returns the invalid content type.
func (e *InvalidContentTypeError) ContentType() string {
return e.contentType
}
// RequestError is the request error from http.Client.
// It is returned from Caller.Call.
type RequestError struct{ error error }
// Error is the implementation of error.
func (e *RequestError) Error() string {
return fmt.Errorf("request error: %w", e.error).Error()
}
// Unwrap unwraps the underlying error.
func (e *RequestError) Unwrap() error {
return e.error
}
// PlainTextError is the plain text error returned from http server.
// It is returned from Caller.Call.
type PlainTextError struct{ error error }
// Error is the implementation of error.
func (e *PlainTextError) Error() string {
return fmt.Errorf("plain text error: %w", e.error).Error()
}
// Unwrap unwraps the underlying error.
func (e *PlainTextError) Unwrap() error {
return e.error
}