From 612332cf4d87ee5c42a4576f82e6273acba1321f Mon Sep 17 00:00:00 2001 From: Justin Chadwell Date: Mon, 21 Oct 2024 13:34:16 +0100 Subject: [PATCH] chore: add disk stat error wrapping While doing some debugging, realized we weren't doing any disk wrapping so it was difficult to work out *which* file on disk didn't exist. Signed-off-by: Justin Chadwell --- util/disk/disk_openbsd.go | 4 +++- util/disk/disk_unix.go | 4 +++- util/disk/disk_windows.go | 5 +++-- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/util/disk/disk_openbsd.go b/util/disk/disk_openbsd.go index 729b071e9e5c..a76664548001 100644 --- a/util/disk/disk_openbsd.go +++ b/util/disk/disk_openbsd.go @@ -5,12 +5,14 @@ package disk import ( "syscall" + + "github.com/pkg/errors" ) func GetDiskStat(root string) (DiskStat, error) { var st syscall.Statfs_t if err := syscall.Statfs(root, &st); err != nil { - return DiskStat{}, err + return DiskStat{}, errors.Wrapf(err, "could not stat fs at %s", root) } return DiskStat{ diff --git a/util/disk/disk_unix.go b/util/disk/disk_unix.go index 37cfeabc1358..00d111142c70 100644 --- a/util/disk/disk_unix.go +++ b/util/disk/disk_unix.go @@ -5,12 +5,14 @@ package disk import ( "syscall" + + "github.com/pkg/errors" ) func GetDiskStat(root string) (DiskStat, error) { var st syscall.Statfs_t if err := syscall.Statfs(root, &st); err != nil { - return DiskStat{}, err + return DiskStat{}, errors.Wrapf(err, "could not stat fs at %s", root) } return DiskStat{ diff --git a/util/disk/disk_windows.go b/util/disk/disk_windows.go index d19df26282ba..7f36e6198824 100644 --- a/util/disk/disk_windows.go +++ b/util/disk/disk_windows.go @@ -4,13 +4,14 @@ package disk import ( + "github.com/pkg/errors" "golang.org/x/sys/windows" ) func GetDiskStat(root string) (DiskStat, error) { rootUTF16, err := windows.UTF16FromString(root) if err != nil { - return DiskStat{}, err + return DiskStat{}, errors.Wrapf(err, "could not encode %s", root) } var ( totalBytes uint64 @@ -22,7 +23,7 @@ func GetDiskStat(root string) (DiskStat, error) { &freeAvailableBytes, &totalBytes, &totalFreeBytes); err != nil { - return DiskStat{}, err + return DiskStat{}, errors.Wrapf(err, "could not stat fs at %s", root) } return DiskStat{