Skip to content

Commit

Permalink
more detailed error messages when openning db
Browse files Browse the repository at this point in the history
  • Loading branch information
Termina1 committed Oct 14, 2024
1 parent 6361f2a commit ca72e9f
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions chotki.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,14 +191,14 @@ func Exists(dirname string) (bool, error) {
func Open(dirname string, opts Options) (*Chotki, error) {
exists, err := Exists(dirname)
if err != nil {
return nil, err
return nil, errors.Join(fmt.Errorf("error when checking db directory"), err)
}

opts.SetDefaults() // todo param

db, err := pebble.Open(dirname, &opts.Options)
if err != nil {
return nil, err
return nil, errors.Join(err, fmt.Errorf("error opening pebble"))
}

absdir, err := filepath.Abs(dirname)
Expand Down Expand Up @@ -271,13 +271,13 @@ func Open(dirname string, opts Options) (*Chotki, error) {
))

if err = cho.Drain(context.Background(), init); err != nil {
return nil, err
return nil, errors.Join(err, fmt.Errorf("unable to drain initial data to chotki"))
}
}

vv, err := cho.VersionVector()
if err != nil {
return nil, err
return nil, errors.Join(fmt.Errorf("unable to get version vector"), err)
}

cho.last = vv.GetID(cho.src)
Expand Down

0 comments on commit ca72e9f

Please sign in to comment.