Better errors for basedir
This commit is contained in:
parent
13ecfb9113
commit
5259ae0689
@ -2,7 +2,6 @@
|
|||||||
package basedir
|
package basedir
|
||||||
|
|
||||||
import "os"
|
import "os"
|
||||||
import "errors"
|
|
||||||
import "path/filepath"
|
import "path/filepath"
|
||||||
|
|
||||||
// Var is an XDG environment variable.
|
// Var is an XDG environment variable.
|
||||||
@ -21,10 +20,15 @@ func (v Var) Value () string {
|
|||||||
return os.Getenv(string(v))
|
return os.Getenv(string(v))
|
||||||
}
|
}
|
||||||
|
|
||||||
// ErrEmpty indicaties a path is empty.
|
type basedirError string
|
||||||
var ErrEmpty = errors.New("path is not absolute")
|
func (err basedirError) Error () string { return string(err) }
|
||||||
// ErrNotAbs indicates a path is not absolute.
|
|
||||||
var ErrNotAbs = errors.New("path is not absolute")
|
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
|
// Valid returns an error if the path is not absolute (beginning from '/') or if
|
||||||
// it is otherwise invalid.
|
// it is otherwise invalid.
|
||||||
|
Loading…
Reference in New Issue
Block a user