-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy patherror.go
More file actions
74 lines (64 loc) · 1.6 KB
/
error.go
File metadata and controls
74 lines (64 loc) · 1.6 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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
package roc
import (
"errors"
"fmt"
)
/* Note:
* This error code list is valid for FlashPACs, FloBoss 500-Series,
* FloBoss 100-Series, and RegFlo.
* ROCPACs and FloBoss 407 have a more complicated error set, which
* depends on a combination of the Opcode and Error code
*/
const (
_ byte = iota
InvalidOpcode
InvalidParameterNumber
InvalidLogicalNumber
InvalidPointType
TooManyBytes
TooFewBytes
DidNotReceive1Byte
DidNotReceive2Byte
DidNotReceive3Byte
DidNotReceive4Byte
DidNotReceive5Byte
DidNotReceive16Byte
OutsideValidAddressRange
InvalidHistoryRequest
InvalidFSTRequest
InvalidEventEntry
RequestedTooManyAlarms
RequestedTooManyEvents
WriteReadOnlyParameter
SecurityError
InvalidSecurityLogon
InvalidStoreAndForwardPath
FlashProgrammingError
HistoryConfigurationInProgress
RequestedSecurityLevelTooHigh byte = 63
)
type ErrorResponseMessage struct {
Message
}
func (err ErrorResponseMessage) GetErrorCode() byte {
return err.Data[0]
}
func (err ErrorResponseMessage) GetCauseOpcode() byte {
return err.Data[1]
}
func (err ErrorResponseMessage) GetCauseByte() byte {
return err.Data[2]
}
func (err ErrorResponseMessage) Error() string {
return fmt.Sprintf("Error code %d caused by byte %d of request with opcode %d", err.GetErrorCode(), err.GetCauseByte(), err.GetCauseOpcode())
}
func errorResponseMessage(message Message) (errResponse ErrorResponseMessage, err error) {
if message.Opcode != ErrorResponse {
err = errors.New("Incorrect Opcode")
} else if len(message.Data) != 3 {
err = errors.New("Incorrect Data Length")
} else {
errResponse.Message = message
}
return
}