I have a method CreateProduct(&Product) error
that returns a value implementing error
interface. It can be a gorm
database error or my own error type.
Having the returned value, how can I know which type is the error?
err = api.ProductManager.CreateProduct(product)
if err != nil {
// TODO: how to distinguish that it is a validation error?
response.WriteHeader(422)
response.WriteJson(err)
return
}