Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not log errors before returning them #191

Merged
merged 1 commit into from Dec 13, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
17 changes: 5 additions & 12 deletions context.go
Expand Up @@ -20,7 +20,6 @@ import (
"bytes"
"fmt"
"io"
"log"
"os"
"path/filepath"
"strings"
Expand Down Expand Up @@ -152,9 +151,7 @@ func (c *context) Resource(p string, fi os.FileInfo) (Resource, error) {
}

base.xattrs, err = c.resolveXAttrs(fp, fi, base)
if err == ErrNotSupported {
log.Printf("resolving xattrs on %s not supported", fp)
} else if err != nil {
if err != nil && err != ErrNotSupported {
return nil, err
}

Expand Down Expand Up @@ -192,8 +189,7 @@ func (c *context) Resource(p string, fi os.FileInfo) (Resource, error) {
if fi.Mode()&os.ModeDevice != 0 {
deviceDriver, ok := c.driver.(driverpkg.DeviceInfoDriver)
if !ok {
log.Printf("device extraction not supported %s", fp)
return nil, ErrNotSupported
return nil, fmt.Errorf("device extraction is not supported for %s: %w", fp, ErrNotSupported)
}

// character and block devices merely need to recover the
Expand All @@ -206,8 +202,7 @@ func (c *context) Resource(p string, fi os.FileInfo) (Resource, error) {
return newDevice(*base, base.paths, major, minor)
}

log.Printf("%q (%v) is not supported", fp, fi.Mode())
return nil, ErrNotFound
return nil, fmt.Errorf("%q (%v) is not supported: %w", fp, fi.Mode(), ErrNotFound)
}

func (c *context) verifyMetadata(resource, target Resource) error {
Expand Down Expand Up @@ -646,8 +641,7 @@ func (c *context) resolveXAttrs(fp string, fi os.FileInfo, base *resource) (map[
if fi.Mode().IsRegular() || fi.Mode().IsDir() {
xattrDriver, ok := c.driver.(driverpkg.XAttrDriver)
if !ok {
log.Println("xattr extraction not supported")
return nil, ErrNotSupported
return nil, fmt.Errorf("xattr extraction is not supported: %w", ErrNotSupported)
}

return xattrDriver.Getxattr(fp)
Expand All @@ -656,8 +650,7 @@ func (c *context) resolveXAttrs(fp string, fi os.FileInfo, base *resource) (map[
if fi.Mode()&os.ModeSymlink != 0 {
lxattrDriver, ok := c.driver.(driverpkg.LXAttrDriver)
if !ok {
log.Println("xattr extraction for symlinks not supported")
return nil, ErrNotSupported
return nil, fmt.Errorf("xattr extraction for symlinks is not supported: %w", ErrNotSupported)
}

return lxattrDriver.LGetxattr(fp)
Expand Down
4 changes: 1 addition & 3 deletions manifest.go
Expand Up @@ -19,7 +19,6 @@ package continuity
import (
"fmt"
"io"
"log"
"os"
"sort"

Expand Down Expand Up @@ -92,8 +91,7 @@ func BuildManifest(ctx Context) (*Manifest, error) {
if err == ErrNotFound {
return nil
}
log.Printf("error getting resource %q: %v", p, err)
return err
return fmt.Errorf("failed to get resource %q: %w", p, err)
}

// add to the hardlink manager
Expand Down