NewError creates a new Error instance with the specified code and message
(code int, msg string)
| 68 | |
| 69 | // NewError creates a new Error instance with the specified code and message |
| 70 | func NewError(code int, msg string) *Error { |
| 71 | if _, ok := codes[code]; ok { |
| 72 | panic(fmt.Sprintf("error code %d already exists, please replace one", code)) |
| 73 | } |
| 74 | |
| 75 | codes[code] = msg |
| 76 | return &Error{ |
| 77 | Code: code, |
| 78 | Msg: msg, |
| 79 | HTTP: determineHTTPStatusCode(code), // Determine default HTTP status code |
| 80 | } |
| 81 | } |
| 82 | |
| 83 | // NewErrorWithStatus creates a new Error instance with the specified code, message, and HTTP status |
| 84 | func NewErrorWithStatus(code int, msg string, status int) *Error { |
no test coverage detected