diff options
author | Matthew Lemon <matt@matthewlemon.com> | 2020-07-28 17:15:06 +0100 |
---|---|---|
committer | Matthew Lemon <matt@matthewlemon.com> | 2020-07-28 17:15:06 +0100 |
commit | 07b695ccaf2c4485c6278f0d543b0bb223abb58c (patch) | |
tree | 81f8419af8a5da5712418145de464f1deb710fbe /pkg | |
parent | cc9f02f678b1fe9f5a5c8c6fda8fafa1bf721b7b (diff) |
fixed bug whereby the program would crash on importing even when no required datamap present
Diffstat (limited to '')
-rw-r--r-- | pkg/datamaps/reader.go | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/pkg/datamaps/reader.go b/pkg/datamaps/reader.go index 1b9a471..9643fcd 100644 --- a/pkg/datamaps/reader.go +++ b/pkg/datamaps/reader.go @@ -191,12 +191,14 @@ func DatamapFromDB(name string, db *sql.DB) (extractedDatamapFile, error) { // ExtractDBDatamap uses a datamap named from the database db to extract values // from the populated spreadsheet file file. func ExtractDBDatamap(name string, file string, db *sql.DB) (extractedData, error) { - xdata := ReadXLSX(file) ddata, err := DatamapFromDB(name, db) // this will need to return an extractedDatamapFile - if err != nil { return nil, err } + if len(ddata) == 0 { + return nil, fmt.Errorf("There is no datamap in the database matching name '%s'. Try running 'datamaps datamap --import...'.", name) + } + xdata := ReadXLSX(file) names := getSheetNames(ddata) outer := make(extractedData, len(names)) |