I was attempting to use the exported gin.Errortype in func (c *Context) Error(err error) *Error but it fails on compilation.
func someFunc(c *gin.Context) {
if u, err := SomeOp(); err != nil {
c.Error(gin.Error{err, gin.ErrorTypePublic, c.Request.URL.String()})
}
}
Here's the compilation error :
cannot use gin.Error literal (type gin.Error) as type error in argument to c.Error: gin.Error does not implement error (Error method has pointer receiver)
If seems like the inteface was improperly implemented here as the reviecer type should not have be an *Error.
This should fix it.
// Implements the error interface
func (msg Error) Error() string {
return msg.Err.Error()
}
I was attempting to use the exported
gin.Errortype infunc (c *Context) Error(err error) *Errorbut it fails on compilation.Here's the compilation error :
cannot use gin.Error literal (type gin.Error) as type error in argument to c.Error: gin.Error does not implement error (Error method has pointer receiver)If seems like the inteface was improperly implemented here as the reviecer type should not have be an *Error.
This should fix it.