diff options
author | 2021-08-25 15:34:33 +0200 | |
---|---|---|
committer | 2021-08-25 15:34:33 +0200 | |
commit | 2dc9fc1626507bb54417fc4a1920b847cafb27a2 (patch) | |
tree | 4ddeac479b923db38090aac8bd9209f3646851c1 /vendor/github.com/go-pg/pg/v10/internal/error.go | |
parent | Manually approves followers (#146) (diff) | |
download | gotosocial-2dc9fc1626507bb54417fc4a1920b847cafb27a2.tar.xz |
Pg to bun (#148)
* start moving to bun
* changing more stuff
* more
* and yet more
* tests passing
* seems stable now
* more big changes
* small fix
* little fixes
Diffstat (limited to 'vendor/github.com/go-pg/pg/v10/internal/error.go')
-rw-r--r-- | vendor/github.com/go-pg/pg/v10/internal/error.go | 61 |
1 files changed, 0 insertions, 61 deletions
diff --git a/vendor/github.com/go-pg/pg/v10/internal/error.go b/vendor/github.com/go-pg/pg/v10/internal/error.go deleted file mode 100644 index ae6524aeb..000000000 --- a/vendor/github.com/go-pg/pg/v10/internal/error.go +++ /dev/null @@ -1,61 +0,0 @@ -package internal - -import ( - "fmt" -) - -var ( - ErrNoRows = Errorf("pg: no rows in result set") - ErrMultiRows = Errorf("pg: multiple rows in result set") -) - -type Error struct { - s string -} - -func Errorf(s string, args ...interface{}) Error { - return Error{s: fmt.Sprintf(s, args...)} -} - -func (err Error) Error() string { - return err.s -} - -type PGError struct { - m map[byte]string -} - -func NewPGError(m map[byte]string) PGError { - return PGError{ - m: m, - } -} - -func (err PGError) Field(k byte) string { - return err.m[k] -} - -func (err PGError) IntegrityViolation() bool { - switch err.Field('C') { - case "23000", "23001", "23502", "23503", "23505", "23514", "23P01": - return true - default: - return false - } -} - -func (err PGError) Error() string { - return fmt.Sprintf("%s #%s %s", - err.Field('S'), err.Field('C'), err.Field('M')) -} - -func AssertOneRow(l int) error { - switch { - case l == 0: - return ErrNoRows - case l > 1: - return ErrMultiRows - default: - return nil - } -} |