Return specific error on walk path too short
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Sat, 30 Jul 2016 20:32:03 +0000 (22:32 +0200)
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Sat, 30 Jul 2016 20:32:03 +0000 (22:32 +0200)
helpers/path.go

index 3c0d530f2389207864bcbc03f11b0a63ba77199e..0c18e5397b6ae04b4916eb121cac593dac573cbe 100644 (file)
@@ -462,6 +462,8 @@ func FindCWD() (string, error) {
        return path, nil
 }
 
+var WalkRootTooShortError = errors.New("Path too short. Stop walking.")
+
 // SymbolicWalk is like filepath.Walk, but it supports the root being a
 // symbolic link. It will still not follow symbolic links deeper down in
 // the file structure
@@ -469,7 +471,7 @@ func SymbolicWalk(fs afero.Fs, root string, walker filepath.WalkFunc) error {
 
        // Sanity check
        if len(root) < 4 {
-               return fmt.Errorf("Path to short, cannot walk the root: %s", root)
+               return WalkRootTooShortError
        }
 
        // Handle the root first