|
1 | 1 | package errorHandler |
2 | 2 |
|
3 | | -import "github.com/wisdom-oss/common-go/v3/types" |
| 3 | +import ( |
| 4 | + "net/http" |
| 5 | + |
| 6 | + "github.com/wisdom-oss/common-go/v3/types" |
| 7 | +) |
4 | 8 |
|
5 | 9 | // Panic is the base types.ServiceError used if the ErrorHandler catches a panic |
6 | 10 | // during the handling of a request. |
7 | 11 | var Panic = &types.ServiceError{ |
8 | 12 | Type: "https://pkg.go.dev/builtin#panic", |
9 | | - Status: 500, |
| 13 | + Status: http.StatusInternalServerError, |
10 | 14 | Title: "Internal Panic", |
11 | 15 | Detail: "The service encountered a panic state during the handling of your request.", |
12 | 16 | } |
13 | 17 |
|
14 | | -// InternalError is the base types.ServiceError if the ErrorHandler only |
15 | | -// received objects implementing the Error() interface and no other errors were |
16 | | -// raised during the handling of the request |
| 18 | +// raised during the handling of the request. |
17 | 19 | var InternalError = &types.ServiceError{ |
18 | 20 | Type: "https://www.rfc-editor.org/rfc/rfc9110#section-15.6.1", |
19 | | - Status: 500, |
| 21 | + Status: http.StatusInternalServerError, |
20 | 22 | Title: "Internal Server Error", |
21 | 23 | Detail: "The service encountered an internal error during the handling of your request", |
22 | 24 | } |
23 | 25 |
|
24 | | -// InvalidTypeProvided is used in the case that an unsupported type has been |
25 | | -// passed to the ErrorHandler |
| 26 | +// passed to the ErrorHandler. |
26 | 27 | var InvalidTypeProvided = &types.ServiceError{ |
27 | 28 | Type: "https://www.rfc-editor.org/rfc/rfc9110#section-16.2", |
28 | | - Status: 999, |
| 29 | + Status: 999, //nolint:mnd |
29 | 30 | Title: "Invalid Error Supplied", |
30 | 31 | Detail: "The content provided to the error handler is invalid", |
31 | 32 | } |
32 | 33 |
|
33 | | -// NotFound is an error used in the NotFoundError handler |
| 34 | +// NotFound is an error used in the NotFoundError handler. |
34 | 35 | var NotFound = &types.ServiceError{ |
35 | 36 | Type: "https://www.rfc-editor.org/rfc/rfc9110#section-15.5.5", |
36 | | - Status: 404, |
| 37 | + Status: http.StatusNotFound, |
37 | 38 | Title: "Route Not Found", |
38 | | - Detail: "The requested route was not found. Please check your request and ensure that the route is correctly set up in the service", |
| 39 | + Detail: "The requested route was not found. Please check your request and ensure that the route is correctly set up in the service", //nolint:lll |
39 | 40 | } |
0 commit comments