2017-05-02 21:35:07 +00:00
|
|
|
// Cross platform errors
|
|
|
|
|
|
|
|
package mountlib
|
|
|
|
|
|
|
|
import "fmt"
|
|
|
|
|
|
|
|
// Error describes low level errors in a cross platform way
|
|
|
|
type Error byte
|
|
|
|
|
2017-05-11 12:15:51 +00:00
|
|
|
// NB if changing errors translateError in cmd/mount/fs.go, cmd/cmount/fs.go
|
|
|
|
|
2017-05-02 21:35:07 +00:00
|
|
|
// Low level errors
|
|
|
|
const (
|
|
|
|
OK Error = iota
|
|
|
|
ENOENT
|
|
|
|
ENOTEMPTY
|
|
|
|
EEXIST
|
|
|
|
ESPIPE
|
|
|
|
EBADF
|
2017-05-11 12:15:51 +00:00
|
|
|
EROFS
|
2017-05-02 21:35:07 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
var errorNames = []string{
|
|
|
|
OK: "Success",
|
|
|
|
ENOENT: "No such file or directory",
|
|
|
|
ENOTEMPTY: "Directory not empty",
|
|
|
|
EEXIST: "File exists",
|
|
|
|
ESPIPE: "Illegal seek",
|
|
|
|
EBADF: "Bad file descriptor",
|
2017-05-11 12:15:51 +00:00
|
|
|
EROFS: "Read only file system",
|
2017-05-02 21:35:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Error renders the error as a string
|
|
|
|
func (e Error) Error() string {
|
|
|
|
if int(e) >= len(errorNames) {
|
|
|
|
return fmt.Sprintf("Low level error %d", e)
|
|
|
|
}
|
|
|
|
return errorNames[e]
|
|
|
|
}
|