Commit 68cab0c2 authored by Han-Wen Nienhuys's avatar Han-Wen Nienhuys

Cleanup of ToStatus().

parent 21a255f0
...@@ -32,22 +32,21 @@ func (code Status) Ok() bool { ...@@ -32,22 +32,21 @@ func (code Status) Ok() bool {
// Convert error back to Errno based errors. // Convert error back to Errno based errors.
func ToStatus(err error) Status { func ToStatus(err error) Status {
if err != nil { if err == nil {
switch t := err.(type) { return OK
case syscall.Errno:
return Status(t)
case *os.SyscallError:
return Status(t.Errno.(syscall.Errno))
case *os.PathError:
return ToStatus(t.Err)
case *os.LinkError:
return ToStatus(t.Err)
default:
log.Println("can't convert error type:", err)
return ENOSYS
}
} }
return OK switch t := err.(type) {
case syscall.Errno:
return Status(t)
case *os.SyscallError:
return Status(t.Errno.(syscall.Errno))
case *os.PathError:
return ToStatus(t.Err)
case *os.LinkError:
return ToStatus(t.Err)
}
log.Println("can't convert error type:", err)
return ENOSYS
} }
func splitDuration(dt time.Duration, secs *uint64, nsecs *uint32) { func splitDuration(dt time.Duration, secs *uint64, nsecs *uint32) {
......
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