Wrap errors

This commit is contained in:
Ettore Di Giacinto
2019-11-04 17:13:53 +01:00
parent 9dc8fccd12
commit b32a6c2286
2 changed files with 6 additions and 3 deletions

View File

@@ -16,12 +16,13 @@
package pkg
import (
"errors"
"os"
"strconv"
"sync"
"time"
"github.com/pkg/errors"
storm "github.com/asdine/storm"
"github.com/asdine/storm/q"
"go.etcd.io/bbolt"
@@ -160,7 +161,7 @@ func (db *BoltDatabase) GetAllPackages(packages chan Package) error {
func (db *BoltDatabase) CreatePackage(p Package) (string, error) {
bolt, err := storm.Open(db.Path, storm.BoltOptions(0600, &bbolt.Options{Timeout: 30 * time.Second}))
if err != nil {
return "", err
return "", errors.Wrap(err, "Error opening boltdb "+db.Path)
}
defer bolt.Close()
@@ -168,9 +169,10 @@ func (db *BoltDatabase) CreatePackage(p Package) (string, error) {
if !ok {
return "", errors.New("Bolt DB support only DefaultPackage type for now")
}
err = bolt.Save(dp)
if err != nil {
return "", err
return "", errors.Wrap(err, "Error saving package to "+db.Path)
}
return strconv.Itoa(dp.ID), err

View File

@@ -26,6 +26,7 @@ import (
"path/filepath"
pkg "github.com/mudler/luet/pkg/package"
"github.com/pkg/errors"
)
const (