Add custom Error type

This commit is contained in:
Alessio 2021-07-24 12:28:30 -07:00
parent 11e3a74b22
commit 5f003c48e9

View File

@ -1,6 +1,7 @@
package persistence
import (
"fmt"
"errors"
"os"
"strings"
@ -8,6 +9,15 @@ import (
"offline_twitter/scraper"
)
var NotInDatabase = errors.New("Not in database")
type ErrNotInDatabase struct {
Table string
Value interface{}
}
func (err ErrNotInDatabase) Error() string {
return fmt.Sprintf("Not in database: %s %q", err.Table, err.Value)
}
// DUPE 1
func file_exists(path string) bool {