aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Lemon <lemon@matthewlemon.com>2020-08-01 17:51:11 +0100
committerMatthew Lemon <lemon@matthewlemon.com>2020-08-01 17:51:11 +0100
commit52cc2c420d0b9f2a3e46769db2bb532a46700452 (patch)
tree73b3ab057d7b72d2afcb180ebe678f0543e50b2b
parent018beb15661ff80a5a79759a21f69d590344b9c4 (diff)
tidying errors
-rw-r--r--pkg/datamaps/writer.go14
1 files changed, 7 insertions, 7 deletions
diff --git a/pkg/datamaps/writer.go b/pkg/datamaps/writer.go
index e820049..9af5207 100644
--- a/pkg/datamaps/writer.go
+++ b/pkg/datamaps/writer.go
@@ -42,12 +42,12 @@ func ExportMaster(opts *Options) error {
// SQLITE CODE
db, err := sql.Open("sqlite3", opts.DBPath)
+ if err != nil {
+ return fmt.Errorf("cannot open database %v", err)
+ }
// Get number amount of datamap keys in target datamap
keyCountRows := db.QueryRow("SELECT count(key) FROM datamap_line, datamap WHERE datamap.name=?;", opts.DMName)
- if err != nil {
- log.Fatal(err)
- }
var datamapKeysNumber int64
if err := keyCountRows.Scan(&datamapKeysNumber); err != nil {
@@ -56,7 +56,7 @@ func ExportMaster(opts *Options) error {
datamapKeysRows, err := db.Query("SELECT key FROM datamap_line, datamap WHERE datamap.name=?;", opts.DMName)
if err != nil {
- log.Fatal(err)
+ return fmt.Errorf("cannot query for keys in database - %v", err)
}
var datamapKeys []string
@@ -66,7 +66,7 @@ func ExportMaster(opts *Options) error {
if k := datamapKeysRows.Next(); k {
var key string
if err := datamapKeysRows.Scan(&key); err != nil {
- return err
+ return fmt.Errorf("cannot Scan for key %s - %v", key, err)
}
datamapKeys = append(datamapKeys, key)
}
@@ -81,9 +81,9 @@ func ExportMaster(opts *Options) error {
GROUP BY datamap_line.key;`
var rowCount int64
- rowCountRes := db.QueryRow(sqlCount, opts.DMName, opts.ReturnName, targetKey)
+ rowCountRes := db.QueryRow(sqlCount, opts.DMName, opts.ReturnName, targetKey) // TODO: fix this
if err != nil {
- return err
+ return fmt.Errorf("cannot query for row count of return data - %v", err)
}
if err := rowCountRes.Scan(&rowCount); err != nil {