mirror of
https://github.com/mudler/luet.git
synced 2025-09-20 02:31:41 +00:00
Wrap errors
This commit is contained in:
@@ -16,12 +16,13 @@
|
|||||||
package pkg
|
package pkg
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
|
||||||
"os"
|
"os"
|
||||||
"strconv"
|
"strconv"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/pkg/errors"
|
||||||
|
|
||||||
storm "github.com/asdine/storm"
|
storm "github.com/asdine/storm"
|
||||||
"github.com/asdine/storm/q"
|
"github.com/asdine/storm/q"
|
||||||
"go.etcd.io/bbolt"
|
"go.etcd.io/bbolt"
|
||||||
@@ -160,7 +161,7 @@ func (db *BoltDatabase) GetAllPackages(packages chan Package) error {
|
|||||||
func (db *BoltDatabase) CreatePackage(p Package) (string, error) {
|
func (db *BoltDatabase) CreatePackage(p Package) (string, error) {
|
||||||
bolt, err := storm.Open(db.Path, storm.BoltOptions(0600, &bbolt.Options{Timeout: 30 * time.Second}))
|
bolt, err := storm.Open(db.Path, storm.BoltOptions(0600, &bbolt.Options{Timeout: 30 * time.Second}))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", errors.Wrap(err, "Error opening boltdb "+db.Path)
|
||||||
}
|
}
|
||||||
defer bolt.Close()
|
defer bolt.Close()
|
||||||
|
|
||||||
@@ -168,9 +169,10 @@ func (db *BoltDatabase) CreatePackage(p Package) (string, error) {
|
|||||||
if !ok {
|
if !ok {
|
||||||
return "", errors.New("Bolt DB support only DefaultPackage type for now")
|
return "", errors.New("Bolt DB support only DefaultPackage type for now")
|
||||||
}
|
}
|
||||||
|
|
||||||
err = bolt.Save(dp)
|
err = bolt.Save(dp)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", errors.Wrap(err, "Error saving package to "+db.Path)
|
||||||
}
|
}
|
||||||
|
|
||||||
return strconv.Itoa(dp.ID), err
|
return strconv.Itoa(dp.ID), err
|
||||||
|
@@ -26,6 +26,7 @@ import (
|
|||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
|
||||||
pkg "github.com/mudler/luet/pkg/package"
|
pkg "github.com/mudler/luet/pkg/package"
|
||||||
|
"github.com/pkg/errors"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
Reference in New Issue
Block a user