refactor: rename backend -> web

This commit is contained in:
2025-01-06 19:25:06 +03:00
parent 7d38326112
commit 521e140881
7 changed files with 0 additions and 0 deletions
+22
View File
@@ -0,0 +1,22 @@
package api
import (
"strconv"
"github.com/jackc/pgx/v5/pgconn"
)
func HandleDBError(err error) (int, string) {
pgErr, ok := err.(*pgconn.PgError)
if !ok {
return 500, err.Error()
}
statusStr := pgErr.Message[:3]
message := pgErr.Message[4:]
status, err := strconv.ParseInt(statusStr, 10, 0)
if err == nil {
return int(status), message
} else {
return 400, pgErr.Message
}
}