dive-zfs/dive/filetree/path_error.go
2019-11-19 09:59:57 -08:00

40 lines
623 B
Go

package filetree
import "fmt"
const (
ActionAdd FileAction = iota
ActionRemove
)
type FileAction int
func (fa FileAction) String() string {
switch fa {
case ActionAdd:
return "add"
case ActionRemove:
return "remove"
default:
return "<unknown file action>"
}
}
type PathError struct {
Path string
Action FileAction
Err error
}
func NewPathError(path string, action FileAction, err error) PathError {
return PathError{
Path: path,
Action: action,
Err: err,
}
}
func (pe PathError) String() string {
return fmt.Sprintf("unable to %s '%s': %+v", pe.Action.String(), pe.Path, pe.Err)
}