aboutsummaryrefslogtreecommitdiff
path: root/spool.go
diff options
context:
space:
mode:
authorJulien Dessaux2020-01-08 11:22:14 +0100
committerJulien Dessaux2020-01-08 15:09:31 +0100
commit4724979262cbbb6792412881fc812ab2101631ef (patch)
tree067e304d64d447ddf013b246905253f3d444f532 /spool.go
parentInitial import (diff)
downloadbareos-zabbix-check-4724979262cbbb6792412881fc812ab2101631ef.tar.gz
bareos-zabbix-check-4724979262cbbb6792412881fc812ab2101631ef.tar.bz2
bareos-zabbix-check-4724979262cbbb6792412881fc812ab2101631ef.zip
Improved error messages and added a readme
Diffstat (limited to '')
-rw-r--r--spool.go12
1 files changed, 5 insertions, 7 deletions
diff --git a/spool.go b/spool.go
index e3d00d9..071a469 100644
--- a/spool.go
+++ b/spool.go
@@ -20,12 +20,12 @@ func loadSpool() (entries jobs, err error) {
// We read the spool
file, err = os.Open(path.Join(workDir, spoolFile))
if err != nil {
- return nil, fmt.Errorf("INFO Couldn't open spool file: %s", err)
+ return nil, fmt.Errorf("Couldn't open spool file, starting from scratch: %s", err)
}
defer file.Close()
lines, err = csv.NewReader(file).ReadAll()
if err != nil {
- return nil, fmt.Errorf("INFO Corrupted spool file : %s", err)
+ return nil, fmt.Errorf("Corrupted spool file, starting from scratch : %s", err)
}
if verbose {
log.Printf("Spool file content : %v\n", lines)
@@ -33,12 +33,10 @@ func loadSpool() (entries jobs, err error) {
entries = make(map[string]uint64)
for _, line := range lines {
- var (
- i int
- )
+ var i int
i, err = strconv.Atoi(line[1])
if err != nil {
- return nil, fmt.Errorf("INFO Corrupted spool file : couldn't parse timestamp entry")
+ return nil, fmt.Errorf("Corrupted spool file : couldn't parse timestamp entry")
}
entries[line[0]] = uint64(i)
}
@@ -55,7 +53,7 @@ func saveSpool(entries jobs) (err error) {
)
file, err = os.Create(path.Join(workDir, spoolFile))
if err != nil {
- return fmt.Errorf("INFO Couldn't open spool file for writing : %s", err)
+ return
}
defer file.Close()