summaryrefslogtreecommitdiff
path: root/internal/db/error.go
diff options
context:
space:
mode:
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")
+)