Commit 8a2ea6d4 authored by Han-Wen Nienhuys's avatar Han-Wen Nienhuys

Use type switch for OsErrorToFuseError().

parent fcc0ed72
...@@ -26,29 +26,19 @@ func MakeTempDir() string { ...@@ -26,29 +26,19 @@ func MakeTempDir() string {
// Convert os.Error back to Errno based errors. // Convert os.Error back to Errno based errors.
func OsErrorToFuseError(err os.Error) Status { func OsErrorToFuseError(err os.Error) Status {
if err != nil { if err != nil {
asErrno, ok := err.(os.Errno) switch t := err.(type) {
if ok { case os.Errno:
return Status(asErrno) return Status(t)
case *os.SyscallError:
return Status(t.Errno)
case *os.PathError:
return OsErrorToFuseError(t.Error)
case *os.LinkError:
return OsErrorToFuseError(t.Error)
default:
log.Println("can't convert error type:", err)
return ENOSYS
} }
asSyscallErr, ok := err.(*os.SyscallError)
if ok {
return Status(asSyscallErr.Errno)
}
asPathErr, ok := err.(*os.PathError)
if ok {
return OsErrorToFuseError(asPathErr.Error)
}
asLinkErr, ok := err.(*os.LinkError)
if ok {
return OsErrorToFuseError(asLinkErr.Error)
}
// Should not happen. Should we log an error somewhere?
log.Println("can't convert error type:", err)
return ENOSYS
} }
return OK return OK
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment