MCPcopy
hub / github.com/gin-gonic/gin / Error

Method Error

context.go:252–268  ·  view source on GitHub ↗

************************************/ ********* ERROR MANAGEMENT *********/ ************************************/ Error attaches an error to the current context. The error is pushed to a list of errors. It's a good idea to call Error for each error that occurred during the resolution of a request. A

(err error)

Source from the content-addressed store, hash-verified

250// print a log, or append it in the HTTP response.
251// Error will panic if err is nil.
252func (c *Context) Error(err error) *Error {
253 if err == nil {
254 panic("err is nil")
255 }
256
257 var parsedError *Error
258 ok := errors.As(err, &parsedError)
259 if !ok {
260 parsedError = &Error{
261 Err: err,
262 Type: ErrorTypePrivate,
263 }
264 }
265
266 c.Errors = append(c.Errors, parsedError)
267 return parsedError
268}
269
270/************************************/
271/******** METADATA MANAGEMENT********/

Callers 2

AbortWithErrorMethod · 0.95
RenderMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected