MCPcopy
hub / github.com/dnote/dnote / DoError

Function DoError

pkg/server/middleware/helpers.go:73–87  ·  view source on GitHub ↗

DoError logs the error and responds with the given status code with a generic status text

(w http.ResponseWriter, msg string, err error, statusCode int)

Source from the content-addressed store, hash-verified

71
72// DoError logs the error and responds with the given status code with a generic status text
73func DoError(w http.ResponseWriter, msg string, err error, statusCode int) {
74 var message string
75 if err == nil {
76 message = msg
77 } else {
78 message = errors.Wrap(err, msg).Error()
79 }
80
81 log.WithFields(log.Fields{
82 "statusCode": statusCode,
83 }).Error(message)
84
85 statusText := http.StatusText(statusCode)
86 http.Error(w, statusText, statusCode)
87}
88
89// NotSupported is the handler for the route that is no longer supported
90func NotSupported(w http.ResponseWriter, r *http.Request) {

Callers 4

GetSyncFragmentMethod · 0.92
GetSyncStateMethod · 0.92
AuthFunction · 0.85
TokenAuthFunction · 0.85

Calls 2

WithFieldsFunction · 0.92
ErrorMethod · 0.45

Tested by

no test coverage detected