diff options
author | Ben Morrison <ben@gbmor.dev> | 2019-06-06 18:16:29 -0400 |
---|---|---|
committer | Ben Morrison <ben@gbmor.dev> | 2019-06-08 02:29:23 -0400 |
commit | 6c1b09bbeb1a7268a0d590e0a20ab2d34b395c8f (patch) | |
tree | 2c843adf344830510ff517f344b3af451955f98c /svc/db.go | |
parent | 5fa9ec1b63acc6ac9dc0a8b5d2f8f044c27ea45e (diff) | |
download | getwtxt-6c1b09bbeb1a7268a0d590e0a20ab2d34b395c8f.tar.gz |
cleaned up error handling
Diffstat (limited to 'svc/db.go')
-rw-r--r-- | svc/db.go | 21 |
1 files changed, 7 insertions, 14 deletions
diff --git a/svc/db.go b/svc/db.go index f5e8678..a6ddf18 100644 --- a/svc/db.go +++ b/svc/db.go @@ -2,13 +2,12 @@ package svc // import "github.com/getwtxt/getwtxt/svc" import ( "database/sql" - "log" "net" "strings" "time" "github.com/getwtxt/registry" - _ "github.com/mattn/go-sqlite3" + _ "github.com/mattn/go-sqlite3" // for the sqlite3 driver "github.com/syndtr/goleveldb/leveldb" ) @@ -45,11 +44,11 @@ func initDatabase() { case "sqlite": var lite *sql.DB lite, err := sql.Open("sqlite3", confObj.DBPath) - errFatal(err) + errFatal("Error opening sqlite3 DB: ", err) litePrep, err := lite.Prepare("CREATE TABLE IF NOT EXISTS getwtxt (urlKey TEXT PRIMARY KEY, isUser BOOL, blobKey TEXT, data BLOB)") - errFatal(err) + errFatal("Error preparing sqlite3 DB: ", err) _, err = litePrep.Exec() - errFatal(err) + errFatal("Error creating sqlite3 DB: ", err) db = &dbSqlite{db: lite} case "postgres": @@ -59,9 +58,7 @@ func initDatabase() { } confObj.Mu.RUnlock() - if err != nil { - log.Fatalf("%v\n", err.Error()) - } + errFatal("", err) dbChan <- db @@ -161,9 +158,7 @@ func (lvl dbLevel) pull() { data.Date = val case "Status": thetime, err := time.Parse(time.RFC3339, split[2]) - if err != nil { - log.Printf("%v\n", err.Error()) - } + errLog("", err) data.Status[thetime] = val } @@ -179,9 +174,7 @@ func (lvl dbLevel) pull() { iter.Release() err := iter.Error() - if err != nil { - log.Printf("Error while pulling DB into registry cache: %v\n", err.Error()) - } + errLog("Error while pulling DB into registry cache: ", err) } func (lite dbSqlite) push() error { |