MCPcopy
hub / github.com/caddyserver/caddy / Error

Function Error

modules/caddyhttp/errors.go:32–53  ·  modules/caddyhttp/errors.go::Error

Error is a convenient way for a Handler to populate the essential fields of a HandlerError. If err is itself a HandlerError, then any essential fields that are not set will be populated.

(statusCode int, err error)

Source from the content-addressed store, hash-verified

30// HandlerError, then any essential fields that are not
31// set will be populated.
32func Error(statusCode int, err error) HandlerError {
33 const idLen = 9
34 var he HandlerError
35 if errors.As(err, &he) {
36 if he.ID == "" {
37 he.ID = randString(idLen, true)
38 }
39 if he.Trace == "" {
40 he.Trace = trace()
41 }
42 if he.StatusCode == 0 {
43 he.StatusCode = statusCode
44 }
45 return he
46 }
47 return HandlerError{
48 ID: randString(idLen, true),
49 StatusCode: statusCode,
50 Err: err,
51 Trace: trace(),
52 }
53}
54
55// HandlerError is a serializable representation of
56// an error from within an HTTP handler.

Callers 15

executeTemplateMethod · 0.92
funcHTTPErrorMethod · 0.92
ServeHTTPMethod · 0.92
ServeHTTPMethod · 0.92
ServeHTTPMethod · 0.92
proxyLoopIterationMethod · 0.92
reverseProxyMethod · 0.92
statusErrorFunction · 0.92
RoundTripMethod · 0.92
DoMethod · 0.92
ServeHTTPMethod · 0.92
ReadMethod · 0.92

Calls 2

randStringFunction · 0.85
traceFunction · 0.85