/
error.go
85 lines (69 loc) · 1.53 KB
/
error.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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
package pubg
// Error interface service API errors
type Error interface {
GetDetail() string
}
// ErrBadRequest structure.
type ErrBadRequest struct {
title string
detail string
}
// GetDetail returns a details.
func (e ErrBadRequest) GetDetail() string {
return e.detail
}
// Error returns a error text.
func (e ErrBadRequest) Error() string {
return "400 " + e.title
}
// ErrUnauthorized structure.
type ErrUnauthorized struct {
title string
detail string
}
// GetDetail returns a details.
func (e ErrUnauthorized) GetDetail() string {
return e.detail
}
// Error returns a error text.
func (e ErrUnauthorized) Error() string {
return "401 " + e.title
}
// ErrNotFound structure.
type ErrNotFound struct {
title string
detail string
}
// GetDetail returns a details.
func (e ErrNotFound) GetDetail() string {
return e.detail
}
// Error returns a error text.
func (e ErrNotFound) Error() string {
return "404 " + e.title
}
// ErrUnsupportedMediaType structure.
type ErrUnsupportedMediaType struct {
title string
detail string
}
// GetDetail returns a details.
func (e ErrUnsupportedMediaType) GetDetail() string {
return e.detail
}
// Error returns a error text.
func (e ErrUnsupportedMediaType) Error() string {
return "415 " + e.title
}
// ErrTooManyRequest structure.
type ErrTooManyRequest struct {
detail string
}
// GetDetail returns a details.
func (e ErrTooManyRequest) GetDetail() string {
return e.detail
}
// Error returns a error text.
func (e ErrTooManyRequest) Error() string {
return "429 Too many request"
}