forked from mtusi2026/mtusi2026lab3
refactor(app) agent refactoring + a little review
This commit is contained in:
@@ -3,6 +3,7 @@ package store
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"log/slog"
|
||||
"net"
|
||||
|
||||
"gitflic.ru/project/bulla-max/mtusi2026lab/internal/common"
|
||||
@@ -15,6 +16,8 @@ func isUniqueViolation(err error) bool {
|
||||
return ok && pgErr.Code == "23505"
|
||||
}
|
||||
|
||||
// dbError maps driver failures to contract errors. Unexpected failures are
|
||||
// logged with their cause so a 500 is never silent.
|
||||
func dbError(err error) error {
|
||||
if err == nil {
|
||||
return nil
|
||||
@@ -36,5 +39,6 @@ func dbError(err error) error {
|
||||
return common.Unavailable("database unavailable")
|
||||
}
|
||||
|
||||
slog.Error("unhandled database error", "err", err)
|
||||
return common.Internal()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user