Better errors for basedir

This commit is contained in:
Sasha Koshka 2024-04-25 02:52:28 -04:00
parent 13ecfb9113
commit 5259ae0689
1 changed files with 9 additions and 5 deletions

View File

@ -2,7 +2,6 @@
package basedir
import "os"
import "errors"
import "path/filepath"
// Var is an XDG environment variable.
@ -21,10 +20,15 @@ func (v Var) Value () string {
return os.Getenv(string(v))
}
// ErrEmpty indicaties a path is empty.
var ErrEmpty = errors.New("path is not absolute")
// ErrNotAbs indicates a path is not absolute.
var ErrNotAbs = errors.New("path is not absolute")
type basedirError string
func (err basedirError) Error () string { return string(err) }
const (
// ErrEmpty indicaties a path is empty.
ErrEmpty = basedirError("path is empty")
// ErrNotAbs indicates a path is not absolute.
ErrNotAbs = basedirError("path is not absolute")
)
// Valid returns an error if the path is not absolute (beginning from '/') or if
// it is otherwise invalid.