aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Lemon <lemon@matthewlemon.com>2020-08-06 16:57:06 +0100
committerMatthew Lemon <lemon@matthewlemon.com>2020-08-06 16:58:08 +0100
commit5e4acc68892172e9cf2fb0e9f6f1caef4a6eed13 (patch)
treee5d2f31178651aa5cb5db9489e6cd0fcee6a591e
parenta19f1c7ad36d469f6749733525ab50b6550e6bdc (diff)
fixing more error messages
-rw-r--r--pkg/datamaps/reader.go10
1 files changed, 6 insertions, 4 deletions
diff --git a/pkg/datamaps/reader.go b/pkg/datamaps/reader.go
index cda52ab..25e6c99 100644
--- a/pkg/datamaps/reader.go
+++ b/pkg/datamaps/reader.go
@@ -155,7 +155,7 @@ func rowVisitor(r *xlsx.Row) error {
func ReadXLSX(path string) FileData {
wb, err := xlsx.OpenFile(path)
if err != nil {
- log.Fatal(err)
+ fmt.Errorf("cannot open file at %s - %v", path, err)
}
outer := make(FileData, 1)
@@ -164,7 +164,7 @@ func ReadXLSX(path string) FileData {
for _, sheet := range wb.Sheets {
if err := sheet.ForEachRow(rowVisitor); err != nil {
- log.Fatal(err)
+ fmt.Errorf("cannot call ForEachRow() in sheet %s - %v", sheet.Name, err)
}
outer[sheet.Name] = inner
inner = make(sheetData)
@@ -189,7 +189,8 @@ func DatamapFromDB(name string, db *sql.DB) (ExtractedDatamapFile, error) {
`
rows, err := db.Query(query, name)
if err != nil {
- return nil, err
+ erstr := fmt.Sprintf("cannot query for datamap key, sheet and cellref - %v", err)
+ return nil, errors.New(erstr)
}
defer rows.Close()
@@ -214,7 +215,8 @@ func DatamapFromDB(name string, db *sql.DB) (ExtractedDatamapFile, error) {
func ExtractDBDatamap(name string, file string, db *sql.DB) (ExtractedData, error) {
ddata, err := DatamapFromDB(name, db) // this will need to return an ExtractedDatamapFile
if err != nil {
- return nil, err
+ erstr := fmt.Sprintf("cannot call DatamapFromDB() - %v", err)
+ return nil, errors.New(erstr)
}
if len(ddata) == 0 {
return nil, fmt.Errorf("there is no datamap in the database matching name '%s'. Try running 'datamaps datamap --import...'", name)