File tree Expand file tree Collapse file tree 1 file changed +15
-4
lines changed Expand file tree Collapse file tree 1 file changed +15
-4
lines changed Original file line number Diff line number Diff line change @@ -80,12 +80,23 @@ func IsExclusionViolation(err error) bool {
80
80
81
81
// Class P0 — PL/pgSQL Error
82
82
83
- func IsPlpgsqlError (err error ) bool {
83
+ func IsPLPGSQLError (err error ) bool {
84
84
var e * pq.Error
85
- return errors .As (err , & e ) && e .Code == "P0000" // plpgsql_error
85
+ return errors .As (err , & e ) && e .Code == "P0000"
86
86
}
87
87
88
- func IsRaiseException (err error ) bool {
88
+ func IsRaisedException (err error ) bool {
89
89
var e * pq.Error
90
- return errors .As (err , & e ) && e .Code == "P0001" // raise_exception
90
+ return errors .As (err , & e ) && e .Code == "P0001"
91
+ }
92
+
93
+ // GetRaisedException returns the message
94
+ // of an PL/pgSQL exception or and empty string
95
+ // if the error is nil or not an exception.
96
+ func GetRaisedException (err error ) string {
97
+ var e * pq.Error
98
+ if errors .As (err , & e ) && e .Code == "P0001" {
99
+ return e .Message
100
+ }
101
+ return ""
91
102
}
You can’t perform that action at this time.
0 commit comments