Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(996)

Side by Side Diff: src/pkg/os/error_plan9.go

Issue 5336045: code review 5336045: os: fixes for error (plan9) (Closed)
Patch Set: diff -r ecbb6b0e6a69 https://go.googlecode.com/hg/ Created 13 years, 4 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/pkg/os/env_plan9.go ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2011 The Go Authors. All rights reserved. 1 // Copyright 2011 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style 2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file. 3 // license that can be found in the LICENSE file.
4 4
5 package os 5 package os
6 6
7 import syscall "syscall" 7 import (
8 » "errors"
9 » "syscall"
10 )
8 11
9 // SyscallError records an error from a specific system call. 12 // SyscallError records an error from a specific system call.
10 type SyscallError struct { 13 type SyscallError struct {
11 Syscall string 14 Syscall string
12 Err string 15 Err string
13 } 16 }
14 17
15 func (e *SyscallError) Error() string { return e.Syscall + ": " + e.Err } 18 func (e *SyscallError) Error() string { return e.Syscall + ": " + e.Err }
16 19
17 // Note: If the name of the function NewSyscallError changes, 20 // Note: If the name of the function NewSyscallError changes,
18 // pkg/go/doc/doc.go should be adjusted since it hardwires 21 // pkg/go/doc/doc.go should be adjusted since it hardwires
19 // this name in a heuristic. 22 // this name in a heuristic.
20 23
21 // NewSyscallError returns, as an error, a new SyscallError 24 // NewSyscallError returns, as an error, a new SyscallError
22 // with the given system call name and error details. 25 // with the given system call name and error details.
23 // As a convenience, if err is nil, NewSyscallError returns nil. 26 // As a convenience, if err is nil, NewSyscallError returns nil.
24 func NewSyscallError(syscall string, err syscall.Error) error { 27 func NewSyscallError(syscall string, err syscall.Error) error {
25 if err == nil { 28 if err == nil {
26 return nil 29 return nil
27 } 30 }
28 return &SyscallError{syscall, err.String()} 31 return &SyscallError{syscall, err.String()}
29 } 32 }
30 33
31 var ( 34 var (
32 » Eshortstat = NewError("stat buffer too small") 35 » Eshortstat = errors.New("stat buffer too small")
33 » Ebadstat = NewError("malformed stat buffer") 36 » Ebadstat = errors.New("malformed stat buffer")
34 » Ebadfd = NewError("fd out of range or not open") 37 » Ebadfd = errors.New("fd out of range or not open")
35 » Ebadarg = NewError("bad arg in system call") 38 » Ebadarg = errors.New("bad arg in system call")
36 » Enotdir = NewError("not a directory") 39 » Enotdir = errors.New("not a directory")
37 » Enonexist = NewError("file does not exist") 40 » Enonexist = errors.New("file does not exist")
38 » Eexist = NewError("file already exists") 41 » Eexist = errors.New("file already exists")
39 » Eio = NewError("i/o error") 42 » Eio = errors.New("i/o error")
40 » Eperm = NewError("permission denied") 43 » Eperm = errors.New("permission denied")
41 44
42 EINVAL = Ebadarg 45 EINVAL = Ebadarg
43 ENOTDIR = Enotdir 46 ENOTDIR = Enotdir
44 ENOENT = Enonexist 47 ENOENT = Enonexist
45 EEXIST = Eexist 48 EEXIST = Eexist
46 EIO = Eio 49 EIO = Eio
47 EACCES = Eperm 50 EACCES = Eperm
48 EPERM = Eperm 51 EPERM = Eperm
49 EISDIR = syscall.EISDIR 52 EISDIR = syscall.EISDIR
50 53
51 » EBADF = NewError("bad file descriptor") 54 » EBADF = errors.New("bad file descriptor")
52 » ENAMETOOLONG = NewError("file name too long") 55 » ENAMETOOLONG = errors.New("file name too long")
53 » ERANGE = NewError("math result not representable") 56 » ERANGE = errors.New("math result not representable")
54 » EPIPE = NewError("Broken Pipe") 57 » EPIPE = errors.New("Broken Pipe")
55 » EPLAN9 = NewError("not supported by plan 9") 58 » EPLAN9 = errors.New("not supported by plan 9")
56 ) 59 )
57 60
58 func iserror(err syscall.Error) bool { 61 func iserror(err syscall.Error) bool {
59 return err != nil 62 return err != nil
60 } 63 }
61 64
62 func Errno(e syscall.Error) syscall.Error { return e } 65 func Errno(e syscall.Error) syscall.Error { return e }
OLDNEW
« no previous file with comments | « src/pkg/os/env_plan9.go ('k') | no next file » | no next file with comments »

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b