util: More error handling

This commit is contained in:
James Shubin
2024-02-21 15:24:32 -05:00
parent 871f0e73c0
commit d887e7fea5

View File

@@ -29,6 +29,9 @@ import (
// FsTree returns a string representation of the file system tree similar to the // FsTree returns a string representation of the file system tree similar to the
// well-known `tree` command. // well-known `tree` command.
func FsTree(fs afero.Fs, name string) (string, error) { func FsTree(fs afero.Fs, name string) (string, error) {
if fs == nil {
return "", fmt.Errorf("nil fs")
}
clean := path.Clean(name) clean := path.Clean(name)
str := clean + "/\n" // named dir str := clean + "/\n" // named dir
if name == "" { if name == "" {