MCPcopy Index your code
hub / github.com/DoNewsCode/core / ExampleError_StatusCode

Function ExampleError_StatusCode

unierr/example_test.go:37–48  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

35}
36
37func ExampleError_StatusCode() {
38 err := errors.New("my stuff is missing")
39 unifiedError := unierr.Wrap(err, codes.NotFound)
40
41 httpStatus := unifiedError.StatusCode()
42 fmt.Println(httpStatus)
43 bytes, _ := unifiedError.MarshalJSON()
44 fmt.Println(string(bytes))
45 // Output:
46 // 404
47 // {"code":5,"message":"my stuff is missing"}
48}
49
50func ExampleError_GRPCStatus() {
51 err := errors.New("my stuff is missing")

Callers

nothing calls this directly

Calls 3

WrapFunction · 0.92
StatusCodeMethod · 0.65
MarshalJSONMethod · 0.45

Tested by

no test coverage detected