From ac5f74988feff196f7b2c0789feec239dc25d359 Mon Sep 17 00:00:00 2001
From: Paul <paul@zom.bi>
Date: Thu, 22 Aug 2019 00:48:48 +0200
Subject: [PATCH] Document database error helpers

---
 internal/database/db.go | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/internal/database/db.go b/internal/database/db.go
index 7786e09..789d2af 100644
--- a/internal/database/db.go
+++ b/internal/database/db.go
@@ -18,10 +18,14 @@ func New(dsn string) (*sqlx.DB, error) {
 	return conn, err
 }
 
+// IsErrNoRows returns true if the error indicates that no rows were
+// returned from the database.
 func IsErrNoRows(err error) bool {
 	return err == sql.ErrNoRows
 }
 
+// IsErrUniqueViolation returns true if the error indicates that a UNIQUE
+// constraint violation has occured.
 func IsErrUniqueViolation(err error) bool {
 	// see if we can cast the error to a Database error type
 	pqErr, ok := err.(*pq.Error)
@@ -38,6 +42,8 @@ func IsErrUniqueViolation(err error) bool {
 	return true
 }
 
+// IsErrForeignKeyViolation returns true if the error indicates that a
+// FOREIGN KEY constraint has been violated due to the requested changes.
 func IsErrForeignKeyViolation(err error) bool {
 	// see if we can cast the error to a Database error type
 	pqErr, ok := err.(*pq.Error)