WithCandidateCode decorates the error with a candidate postgres error code. It is called "candidate" because the code is only used by GetPGCode() below conditionally. The code is considered PII-free and is thus reportable.
(err error, code pgcode.Code)
| 37 | // by GetPGCode() below conditionally. |
| 38 | // The code is considered PII-free and is thus reportable. |
| 39 | func WithCandidateCode(err error, code pgcode.Code) error { |
| 40 | if err == nil { |
| 41 | return nil |
| 42 | } |
| 43 | |
| 44 | return &withCandidateCode{cause: err, code: code.String()} |
| 45 | } |
| 46 | |
| 47 | // HasCandidateCode returns tue iff the error or one of its causes |
| 48 | // has a candidate pg error code. |
no test coverage detected