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

Method MarshalJSON

unierr/error.go:105–113  ·  view source on GitHub ↗

MarshalJSON implements json.Marshaler.

()

Source from the content-addressed store, hash-verified

103
104// MarshalJSON implements json.Marshaler.
105func (e *Error) MarshalJSON() (result []byte, err error) {
106 var jsonRepresentation struct {
107 Code uint32 `json:"code,omitempty"`
108 Error string `json:"message"`
109 }
110 jsonRepresentation.Code = uint32(e.code)
111 jsonRepresentation.Error = e.Error()
112 return json.Marshal(jsonRepresentation)
113}
114
115// Error implements error. it consults the Printer for the output.
116func (e *Error) Error() string {

Callers 2

ExampleError_StatusCodeFunction · 0.45

Calls 2

ErrorMethod · 0.95
MarshalMethod · 0.65

Tested by 2

ExampleError_StatusCodeFunction · 0.36