Blame


1 8a7ec697 2015-10-26 adrien package p9pnew
2 8a7ec697 2015-10-26 adrien
3 8a7ec697 2015-10-26 adrien import (
4 8a7ec697 2015-10-26 adrien "errors"
5 8a7ec697 2015-10-26 adrien "fmt"
6 8a7ec697 2015-10-26 adrien )
7 8a7ec697 2015-10-26 adrien
8 c979b5e1 2015-10-28 stephen.d // common errors returned by Session interface methods
9 c979b5e1 2015-10-28 stephen.d var (
10 c979b5e1 2015-10-28 stephen.d ErrClosed = errors.New("closed")
11 c979b5e1 2015-10-28 stephen.d )
12 c979b5e1 2015-10-28 stephen.d
13 c979b5e1 2015-10-28 stephen.d // 9p wire errors returned by Session interface methods
14 c979b5e1 2015-10-28 stephen.d var (
15 c979b5e1 2015-10-28 stephen.d ErrBadattach = new9pError("unknown specifier in attach")
16 c979b5e1 2015-10-28 stephen.d ErrBadoffset = new9pError("bad offset")
17 c979b5e1 2015-10-28 stephen.d ErrBadcount = new9pError("bad count")
18 c979b5e1 2015-10-28 stephen.d ErrBotch = new9pError("9P protocol botch")
19 c979b5e1 2015-10-28 stephen.d ErrCreatenondir = new9pError("create in non-directory")
20 c979b5e1 2015-10-28 stephen.d ErrDupfid = new9pError("duplicate fid")
21 c979b5e1 2015-10-28 stephen.d ErrDuptag = new9pError("duplicate tag")
22 c979b5e1 2015-10-28 stephen.d ErrIsdir = new9pError("is a directory")
23 c979b5e1 2015-10-28 stephen.d ErrNocreate = new9pError("create prohibited")
24 c979b5e1 2015-10-28 stephen.d ErrNomem = new9pError("out of memory")
25 c979b5e1 2015-10-28 stephen.d ErrNoremove = new9pError("remove prohibited")
26 c979b5e1 2015-10-28 stephen.d ErrNostat = new9pError("stat prohibited")
27 c979b5e1 2015-10-28 stephen.d ErrNotfound = new9pError("file not found")
28 c979b5e1 2015-10-28 stephen.d ErrNowrite = new9pError("write prohibited")
29 c979b5e1 2015-10-28 stephen.d ErrNowstat = new9pError("wstat prohibited")
30 c979b5e1 2015-10-28 stephen.d ErrPerm = new9pError("permission denied")
31 c979b5e1 2015-10-28 stephen.d ErrUnknownfid = new9pError("unknown fid")
32 c979b5e1 2015-10-28 stephen.d ErrBaddir = new9pError("bad directory in wstat")
33 c979b5e1 2015-10-28 stephen.d ErrWalknodir = new9pError("walk in non-directory")
34 c979b5e1 2015-10-28 stephen.d
35 c979b5e1 2015-10-28 stephen.d // extra errors not part of the normal protocol
36 c979b5e1 2015-10-28 stephen.d ErrTimeout = new9pError("fcall timeout") // returned when timing out on the fcall
37 c979b5e1 2015-10-28 stephen.d )
38 c979b5e1 2015-10-28 stephen.d
39 c979b5e1 2015-10-28 stephen.d type error9p struct {
40 8a7ec697 2015-10-26 adrien Name string
41 8a7ec697 2015-10-26 adrien }
42 8a7ec697 2015-10-26 adrien
43 c979b5e1 2015-10-28 stephen.d func new9pError(s string) error {
44 97423e8b 2015-10-29 stephen.d return error9p{Name: s}
45 8a7ec697 2015-10-26 adrien }
46 8a7ec697 2015-10-26 adrien
47 c979b5e1 2015-10-28 stephen.d func (e error9p) Error() string {
48 c979b5e1 2015-10-28 stephen.d return fmt.Sprintf("9p: %v", e.Name)
49 c979b5e1 2015-10-28 stephen.d }