-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patherror.go
More file actions
47 lines (42 loc) · 1.38 KB
/
error.go
File metadata and controls
47 lines (42 loc) · 1.38 KB
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
package gerte
import "fmt"
// GertError is the Error Code in a "Failed" Status
type GertError byte
const (
// ErrorVersion indicates that an incompatible version was used during negotiation.
ErrorVersion GertError = iota
// ErrorBadKey indicates that the Key did not match that used for the requested address.
// Requested address may not exist
ErrorBadKey
// ErrorAlreadyRegistered indicates that Registration has already been performed successfully
ErrorAlreadyRegistered
// ErrorNotRegistered indicates that the Gateway hasn't been registered yet.
// The gateway cannot send data before claiming an address
ErrorNotRegistered
// ErrorNoRoute indicates that Data failed to send because the remote gateway couldn't be found
ErrorNoRoute
// ErrorAddressTaken indicates that the Address request has already been claimed
ErrorAddressTaken
)
// PrintError prints a GERT Error to a Human-readable string
func (error GertError) String() string {
switch error {
case ErrorVersion:
return "VERSION"
case ErrorBadKey:
return "BAD_KEY"
case ErrorAlreadyRegistered:
return "ALREADY_REGISTERED"
case ErrorNotRegistered:
return "NOT_REGISTERED"
case ErrorNoRoute:
return "NO_ROUTE"
case ErrorAddressTaken:
return "ADDRESS_TAKEN"
}
return "nil"
}
// PrintError prints a GERT Error to a Human-readable string
func (error GertError) GoString() string {
return fmt.Sprintf("[%v]", error)
}