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

Use type switch for OsErrorToFuseError().

parent fcc0ed72
...@@ -26,30 +26,20 @@ func MakeTempDir() string { ...@@ -26,30 +26,20 @@ 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)
asSyscallErr, ok := err.(*os.SyscallError) case *os.PathError:
if ok { return OsErrorToFuseError(t.Error)
return Status(asSyscallErr.Errno) case *os.LinkError:
} return OsErrorToFuseError(t.Error)
default:
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) log.Println("can't convert error type:", err)
return ENOSYS 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