MCPcopy Index your code
hub / github.com/gogf/gf / HasCode

Function HasCode

errors/gerror/gerror_api_code.go:131–142  ·  view source on GitHub ↗

HasCode checks and reports whether `err` has `code` in its chaining errors.

(err error, code gcode.Code)

Source from the content-addressed store, hash-verified

129
130// HasCode checks and reports whether `err` has `code` in its chaining errors.
131func HasCode(err error, code gcode.Code) bool {
132 if err == nil {
133 return false
134 }
135 if e, ok := err.(ICode); ok && code == e.Code() {
136 return true
137 }
138 if e, ok := err.(IUnwrap); ok {
139 return HasCode(e.Unwrap(), code)
140 }
141 return false
142}

Callers 2

ExampleHasCodeFunction · 0.92
Test_HasCodeFunction · 0.92

Calls 2

CodeMethod · 0.65
UnwrapMethod · 0.65

Tested by 2

ExampleHasCodeFunction · 0.74
Test_HasCodeFunction · 0.74

Used in the wild real call sites across dependent graphs

searching dependent graphs…