mirror of
https://github.com/gin-gonic/gin.git
synced 2025-10-14 12:12:12 +08:00
Add a gracefull method to set error Context#GraceError.
This commit is contained in:
parent
5612cadb73
commit
98a6a283a5
10
context.go
10
context.go
@ -186,6 +186,16 @@ func (c *Context) AbortWithError(code int, err error) *Error {
|
|||||||
return c.Error(err)
|
return c.Error(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GraceError calls `Error` internally.
|
||||||
|
// This method does not panic when err is nil, and no return value.
|
||||||
|
// See Context.Error() for more details.
|
||||||
|
func (c *Context) GraceError(err error) {
|
||||||
|
if err == nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
c.Error(err) // nolint: errcheck
|
||||||
|
}
|
||||||
|
|
||||||
/************************************/
|
/************************************/
|
||||||
/********* ERROR MANAGEMENT *********/
|
/********* ERROR MANAGEMENT *********/
|
||||||
/************************************/
|
/************************************/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user