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

Function determineHTTPStatusCode

api/error_code/error_code.go:148–168  ·  view source on GitHub ↗

determineHTTPStatusCode maps error codes to HTTP status codes

(code int)

Source from the content-addressed store, hash-verified

146
147// determineHTTPStatusCode maps error codes to HTTP status codes
148func determineHTTPStatusCode(code int) int {
149 switch code {
150 case SuccessCode:
151 return http.StatusOK
152 case ServerErrorCode:
153 return http.StatusInternalServerError
154 case InvalidParamsCode:
155 return http.StatusBadRequest
156 case NotFoundCode:
157 return http.StatusNotFound
158 case UnauthorizedAuthNotExistErrorCode,
159 UnauthorizedTokenErrorCode,
160 UnauthorizedTokenGenerateErrorCode,
161 UnauthorizedTokenTimeoutErrorCode:
162 return http.StatusUnauthorized
163 case TooManyRequestsCode:
164 return http.StatusTooManyRequests
165 default:
166 return http.StatusInternalServerError
167 }
168}

Callers 2

NewErrorFunction · 0.85
StatusCodeMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected