This commit is contained in:
Eduard S
2021-02-10 11:09:43 +01:00
parent 104b277de0
commit e737aebd28

View File

@@ -38,7 +38,7 @@ var (
) )
func retSQLErr(err error, c *gin.Context) { func retSQLErr(err error, c *gin.Context) {
log.Warn("HTTP API SQL request error", "err", err) log.Warnw("HTTP API SQL request error", "err", err)
if sqlErr, ok := tracerr.Unwrap(err).(*pq.Error); ok { if sqlErr, ok := tracerr.Unwrap(err).(*pq.Error); ok {
// https://www.postgresql.org/docs/current/errcodes-appendix.html // https://www.postgresql.org/docs/current/errcodes-appendix.html
if sqlErr.Code == "23505" { if sqlErr.Code == "23505" {
@@ -59,7 +59,7 @@ func retSQLErr(err error, c *gin.Context) {
} }
func retBadReq(err error, c *gin.Context) { func retBadReq(err error, c *gin.Context) {
log.Warn("HTTP API Bad request error", "err", err) log.Warnw("HTTP API Bad request error", "err", err)
c.JSON(http.StatusBadRequest, errorMsg{ c.JSON(http.StatusBadRequest, errorMsg{
Message: err.Error(), Message: err.Error(),
}) })