mirror of
https://github.com/rclone/rclone.git
synced 2024-12-23 15:38:57 +01:00
36 lines
620 B
Go
36 lines
620 B
Go
// Cross platform errors
|
|
|
|
package mountlib
|
|
|
|
import "fmt"
|
|
|
|
// Error describes low level errors in a cross platform way
|
|
type Error byte
|
|
|
|
// Low level errors
|
|
const (
|
|
OK Error = iota
|
|
ENOENT
|
|
ENOTEMPTY
|
|
EEXIST
|
|
ESPIPE
|
|
EBADF
|
|
)
|
|
|
|
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",
|
|
}
|
|
|
|
// 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]
|
|
}
|