Skip to content

Commit

Permalink
chg: use sentinel errors
Browse files Browse the repository at this point in the history
  • Loading branch information
HeikoSchlittermann committed Sep 29, 2024
1 parent fa05913 commit 7299137
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion gledki.go
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ func (t *Gledki) findRoots(roots []string) error {
t.Roots = append(t.Roots, root)
continue
} else {
return fmt.Errorf("Gledki root directory '%s' does not exist!", root)
return fmt.Errorf("Gledki root directory %s: %w", root, os.ErrNotExist)
}
}
return nil
Expand Down
8 changes: 4 additions & 4 deletions gledki_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package gledki

import (
"bytes"
"errors"
"fmt"
"io"
"io/fs"
Expand Down Expand Up @@ -293,11 +294,10 @@ func TestFtExecString(t *testing.T) {
func TestErrors(t *testing.T) {

if _, err := New([]string{"/ala/bala/nica"}, filesExt, tagsPair, false); err != nil {
errstr := err.Error()
if strings.Contains(errstr, "does not exist") {
t.Logf("Right error: %s", errstr)
if errors.Is(err, os.ErrNotExist) {
t.Logf("Right error: %v", err)
} else {
t.Fatalf("Wrong error: %s", errstr)
t.Fatalf("Wrong error: %v", err)
}
} else {
t.Fatal("No error - this is unexpected!")
Expand Down

0 comments on commit 7299137

Please sign in to comment.