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

Function ProcessError

pkg/webhandlers/error.go:55–63  ·  view source on GitHub ↗

ProcessError processes an HTTP error by converting it if appropriate, and determining the HTTP status code to return.

(in error)

Source from the content-addressed store, hash-verified

53// ProcessError processes an HTTP error by converting it if appropriate, and
54// determining the HTTP status code to return.
55func ProcessError(in error) (statusCode int, err error) {
56 statusCode, err = http.StatusInternalServerError, in
57 if ttnErr, ok := errors.From(err); ok {
58 statusCode = errors.ToHTTPStatusCode(ttnErr)
59 return statusCode, ttnErr
60 }
61 ttnErr := errors.FromHTTPStatusCode(statusCode, "message")
62 return statusCode, ttnErr.WithCause(err).WithAttributes("message", err.Error())
63}
64
65type errorHandlersKeyType struct{}
66

Callers 1

ErrorFunction · 0.85

Calls 6

FromFunction · 0.92
ToHTTPStatusCodeFunction · 0.92
FromHTTPStatusCodeFunction · 0.92
ErrorMethod · 0.65
WithAttributesMethod · 0.45
WithCauseMethod · 0.45

Tested by

no test coverage detected