refactor(api): rename database error handler function

This commit is contained in:
Masahiko AMANO 2025-01-06 15:16:55 +03:00
parent adcc7d22c3
commit 82134a8cd2
2 changed files with 3 additions and 3 deletions

View File

@ -25,7 +25,7 @@ func userAuth(c *gin.Context) {
}
user, err := db.UserAuth(context.Background(), credentials.Login, credentials.Password)
if err != nil {
status, message := HandlePgError(err)
status, message := HandleDBError(err)
c.JSON(status, gin.H{"error": message})
return
}
@ -81,7 +81,7 @@ func quotesGet(c *gin.Context) {
}
quotes, err := db.QuotesGet(c, user_id, filter, sort, int(limit), int(offset))
if err != nil {
status, message := HandlePgError(err)
status, message := HandleDBError(err)
c.JSON(status, gin.H{"error": message})
return
}

View File

@ -6,7 +6,7 @@ import (
"github.com/jackc/pgx/v5/pgconn"
)
func HandlePgError(err error) (int, string) {
func HandleDBError(err error) (int, string) {
pgErr, ok := err.(*pgconn.PgError)
if !ok {
return 500, err.Error()