style: prefer stdlib idioms for errors and http methods
This commit is contained in:
@@ -6,19 +6,19 @@ import (
|
||||
"path/filepath"
|
||||
"time"
|
||||
|
||||
bolt "go.etcd.io/bbolt"
|
||||
"go.etcd.io/bbolt"
|
||||
bolterrors "go.etcd.io/bbolt/errors"
|
||||
)
|
||||
|
||||
type Store struct {
|
||||
db *bolt.DB
|
||||
db *bbolt.DB
|
||||
}
|
||||
|
||||
func Open(dir string) (*Store, error) {
|
||||
db, err := bolt.Open(filepath.Join(dir, ".tracks.db"), 0600, &bolt.Options{Timeout: 5 * time.Second})
|
||||
db, err := bbolt.Open(filepath.Join(dir, ".tracks.db"), 0600, &bbolt.Options{Timeout: 5 * time.Second})
|
||||
if err != nil {
|
||||
if errors.Is(err, bolterrors.ErrTimeout) {
|
||||
return nil, fmt.Errorf("database is already in use by another process")
|
||||
return nil, errors.New("database is already in use by another process")
|
||||
}
|
||||
return nil, fmt.Errorf("failed to open database: %w", err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user