MCPcopy
hub / github.com/gogf/gf / NewCode

Function NewCode

errors/gerror/gerror_api_code.go:16–22  ·  view source on GitHub ↗

NewCode creates and returns an error that has error code and given text.

(code gcode.Code, text ...string)

Source from the content-addressed store, hash-verified

14
15// NewCode creates and returns an error that has error code and given text.
16func NewCode(code gcode.Code, text ...string) error {
17 return &Error{
18 stack: callers(),
19 text: strings.Join(text, commaSeparatorSpace),
20 code: code,
21 }
22}
23
24// NewCodef returns an error that has error code and formats as the given format and args.
25func NewCodef(code gcode.Code, format string, args ...any) error {

Callers 15

PutMethod · 0.92
GetMethod · 0.92
NewFunction · 0.92
ProceedMethod · 0.92
WatchMethod · 0.92
FormatUpsertMethod · 0.92
FormatUpsertMethod · 0.92
FormatUpsertMethod · 0.92
HandleResponseMethod · 0.92
UnaryErrorMethod · 0.92
UnaryValidateMethod · 0.92

Calls 2

callersFunction · 0.85
JoinMethod · 0.45

Tested by 11

ExampleNewCodeFunction · 0.74
ExampleEqualFunction · 0.74
ExampleCodeFunction · 0.74
ExampleHasCodeFunction · 0.74
Test_CodeFunction · 0.74
Test_Code_WithIUnwrapFunction · 0.74
Benchmark_NewCodeFunction · 0.74
Test_Error_CodeFunction · 0.74

Used in the wild real call sites across dependent graphs

searching dependent graphs…