/
error.go
48 lines (45 loc) · 1.09 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
package handler
import "net/http"
var errorResponses = map[string]errorResponse{
"internal_server_error": {
Code: 1,
Message: "internal server error",
StatusCode: http.StatusInternalServerError,
},
"invalid_id": {
Code: 2,
Message: "invalid id",
StatusCode: http.StatusNotFound,
},
"malformed_request_body": {
Code: 3,
Message: "malformed request body",
StatusCode: http.StatusBadRequest,
},
"request_validation_failed": {
Code: 4,
Message: "request validation failed",
StatusCode: http.StatusBadRequest,
},
"webhook_not_found": {
Code: 5,
Message: "webhook not found",
StatusCode: http.StatusNotFound,
},
"delivery_not_found": {
Code: 6,
Message: "delivery not found",
StatusCode: http.StatusNotFound,
},
"delivery_attempt_not_found": {
Code: 7,
Message: "delivery attempt not found",
StatusCode: http.StatusNotFound,
},
}
type errorResponse struct {
Code int `json:"code"`
Message string `json:"message"`
Details string `json:"details,omitempty"`
StatusCode int `json:"-"`
}