File tree Expand file tree Collapse file tree 2 files changed +14
-0
lines changed Expand file tree Collapse file tree 2 files changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -53,8 +53,18 @@ const (
53
53
// that are are only allowed within DB transactions
54
54
// when the DB connection is not a transaction.
55
55
ErrNotWithinTransaction sentinelError = "not within a transaction"
56
+
57
+ ErrNullValueNotAllowed sentinelError = "null value not allowed"
56
58
)
57
59
60
+ type ErrRaisedException struct {
61
+ Message string
62
+ }
63
+
64
+ func (e ErrRaisedException ) Error () string {
65
+ return "raised exception: " + e .Message
66
+ }
67
+
58
68
type ErrIntegrityConstraintViolation struct {
59
69
Constraint string
60
70
}
Original file line number Diff line number Diff line change @@ -17,6 +17,8 @@ func WrapKnownErrors(err error) error {
17
17
var e * pq.Error
18
18
if errors .As (err , & e ) {
19
19
switch e .Code {
20
+ case "22004" :
21
+ return errors .Join (sqldb .ErrNullValueNotAllowed , err )
20
22
case "23000" :
21
23
return errors .Join (sqldb.ErrIntegrityConstraintViolation {Constraint : e .Constraint }, err )
22
24
case "23001" :
@@ -31,6 +33,8 @@ func WrapKnownErrors(err error) error {
31
33
return errors .Join (sqldb.ErrCheckViolation {Constraint : e .Constraint }, err )
32
34
case "23P01" :
33
35
return errors .Join (sqldb.ErrExclusionViolation {Constraint : e .Constraint }, err )
36
+ case "P0001" :
37
+ return errors .Join (sqldb.ErrRaisedException {Message : e .Message }, err )
34
38
}
35
39
}
36
40
return err
You can’t perform that action at this time.
0 commit comments