MCPcopy Create free account
hub / github.com/TheThingsNetwork/lorawan-stack / ToHTTPStatusCode

Function ToHTTPStatusCode

pkg/errors/http.go:64–75  ·  view source on GitHub ↗

ToHTTPStatusCode maps an error to HTTP response codes.

(err error)

Source from the content-addressed store, hash-verified

62
63// ToHTTPStatusCode maps an error to HTTP response codes.
64func ToHTTPStatusCode(err error) int {
65 for _, err := range Stack(err) {
66 code := Code(err)
67 if code == uint32(codes.Unknown) {
68 continue
69 }
70 if status, ok := httpStatusCodes[code]; ok {
71 return status
72 }
73 }
74 return http.StatusInternalServerError
75}
76
77// FromHTTPStatusCode maps an HTTP response code to an error.
78func FromHTTPStatusCode(status int, publicAttributes ...string) *Error {

Callers 4

writeErrorFunction · 0.92
TestCodesFunction · 0.92
ProcessErrorFunction · 0.92
ToHTTPFunction · 0.85

Calls 2

StackFunction · 0.70
CodeFunction · 0.70

Tested by 1

TestCodesFunction · 0.74