summaryrefslogtreecommitdiff
path: root/internal/db/error.go
diff options
context:
space:
mode:
authorLibravatar tobi <31960611+tsmethurst@users.noreply.github.com>2021-08-20 12:26:56 +0200
committerLibravatar GitHub <noreply@github.com>2021-08-20 12:26:56 +0200
commit4920229a3b6e1d7dde536bc9ff766542b05d935c (patch)
treea9423beccec5331c372f01eedf38949dfb171e9e /internal/db/error.go
parentText/status parsing fixes (#141) (diff)
downloadgotosocial-4920229a3b6e1d7dde536bc9ff766542b05d935c.tar.xz
Database updates (#144)
* start moving some database stuff around * continue moving db stuff around * more fiddling * more updates * and some more * and yet more * i broke SOMETHING but what, it's a mystery * tidy up * vendor ttlcache * use ttlcache * fix up some tests * rename some stuff * little reminder * some more updates
Diffstat (limited to 'internal/db/error.go')
-rw-r--r--internal/db/error.go28
1 files changed, 15 insertions, 13 deletions
diff --git a/internal/db/error.go b/internal/db/error.go
index 197c7bd68..c13bd78dd 100644
--- a/internal/db/error.go
+++ b/internal/db/error.go
@@ -18,16 +18,18 @@
package db
-// ErrNoEntries is to be returned from the DB interface when no entries are found for a given query.
-type ErrNoEntries struct{}
-
-func (e ErrNoEntries) Error() string {
- return "no entries"
-}
-
-// ErrAlreadyExists is to be returned from the DB interface when an entry already exists for a given query or its constraints.
-type ErrAlreadyExists struct{}
-
-func (e ErrAlreadyExists) Error() string {
- return "already exists"
-}
+import "fmt"
+
+// Error denotes a database error.
+type Error error
+
+var (
+ // ErrNoEntries is returned when a caller expected an entry for a query, but none was found.
+ ErrNoEntries Error = fmt.Errorf("no entries")
+ // ErrMultipleEntries is returned when a caller expected ONE entry for a query, but multiples were found.
+ ErrMultipleEntries Error = fmt.Errorf("multiple entries")
+ // ErrAlreadyExists is returned when a caller tries to insert a database entry that already exists in the db.
+ ErrAlreadyExists Error = fmt.Errorf("already exists")
+ // ErrUnknown denotes an unknown database error.
+ ErrUnknown Error = fmt.Errorf("unknown error")
+)