MCPcopy Create free account
hub / github.com/RanchoCooper/go-hexagonal / NewError

Function NewError

api/error_code/error_code.go:70–81  ·  view source on GitHub ↗

NewError creates a new Error instance with the specified code and message

(code int, msg string)

Source from the content-addressed store, hash-verified

68
69// NewError creates a new Error instance with the specified code and message
70func 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
84func NewErrorWithStatus(code int, msg string, status int) *Error {

Callers 1

error_code.goFile · 0.85

Calls 1

determineHTTPStatusCodeFunction · 0.85

Tested by

no test coverage detected