This repository has been archived by the owner on Mar 11, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 50
/
errors.go
58 lines (50 loc) · 1.97 KB
/
errors.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
package p9p
import (
"errors"
"fmt"
)
// MessageRerror provides both a Go error type and message type.
type MessageRerror struct {
Ename string
}
// 9p wire errors returned by Session interface methods
var (
ErrBadattach = new9pError("unknown specifier in attach")
ErrBadoffset = new9pError("bad offset")
ErrBadcount = new9pError("bad count")
ErrBotch = new9pError("9P protocol botch")
ErrCreatenondir = new9pError("create in non-directory")
ErrDupfid = new9pError("duplicate fid")
ErrDuptag = new9pError("duplicate tag")
ErrIsdir = new9pError("is a directory")
ErrNocreate = new9pError("create prohibited")
ErrNomem = new9pError("out of memory")
ErrNoremove = new9pError("remove prohibited")
ErrNostat = new9pError("stat prohibited")
ErrNotfound = new9pError("file not found")
ErrNowrite = new9pError("write prohibited")
ErrNowstat = new9pError("wstat prohibited")
ErrPerm = new9pError("permission denied")
ErrUnknownfid = new9pError("unknown fid")
ErrBaddir = new9pError("bad directory in wstat")
ErrWalknodir = new9pError("walk in non-directory")
// extra errors not part of the normal protocol
ErrTimeout = new9pError("fcall timeout") // returned when timing out on the fcall
ErrUnknownTag = new9pError("unknown tag")
ErrUnknownMsg = new9pError("unknown message") // returned when encountering unknown message type
ErrUnexpectedMsg = new9pError("unexpected message") // returned when an unexpected message is encountered
ErrWalkLimit = new9pError("too many wnames in walk")
ErrClosed = errors.New("closed")
)
// new9pError returns a new 9p error ready for the wire.
func new9pError(s string) error {
return MessageRerror{Ename: s}
}
// Type ensures that 9p errors can be transparently used as a 9p message in an
// Fcall.
func (MessageRerror) Type() FcallType {
return Rerror
}
func (e MessageRerror) Error() string {
return fmt.Sprintf("9p: %v", e.Ename)
}