fix: error handling in auth service for database; refactor: removed redundant taken email check; chore: removed todos that were completed/not needed; fix: leaking transactions in complete registration and login on error; refactor: got rid of txless requests during transactions;
18 lines
265 B
Go
18 lines
265 B
Go
package errors
|
|
|
|
import (
|
|
"errors"
|
|
|
|
"github.com/jackc/pgx/v5/pgconn"
|
|
)
|
|
|
|
func GetPgError(err error) string {
|
|
var pgErr *pgconn.PgError
|
|
errors.As(err, &pgErr)
|
|
return pgErr.Code
|
|
}
|
|
|
|
func MatchPgError(err error, code string) bool {
|
|
return GetPgError(err) == code
|
|
}
|