MCPcopy Index your code
hub / github.com/cockroachdb/errors / GetHTTPCode

Function GetHTTPCode

exthttp/ext_http.go:45–55  ·  view source on GitHub ↗

GetHTTPCode retrieves the HTTP code from a stack of causes.

(err error, defaultCode int)

Source from the content-addressed store, hash-verified

43
44// GetHTTPCode retrieves the HTTP code from a stack of causes.
45func GetHTTPCode(err error, defaultCode int) int {
46 if v, ok := markers.If(err, func(err error) (interface{}, bool) {
47 if w, ok := err.(*withHTTPCode); ok {
48 return w.code, true
49 }
50 return nil, false
51 }); ok {
52 return v.(int)
53 }
54 return defaultCode
55}
56
57// it's an error.
58func (w *withHTTPCode) Error() string { return w.cause.Error() }

Callers 1

TestHTTPFunction · 0.92

Calls 1

IfFunction · 0.92

Tested by 1

TestHTTPFunction · 0.74

Used in the wild real call sites across dependent graphs

searching dependent graphs…