-
Notifications
You must be signed in to change notification settings - Fork 50
/
errors.go
36 lines (29 loc) · 864 Bytes
/
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
package routeros
import (
"errors"
"fmt"
"gopkg.in/routeros.v1/proto"
)
var (
errAlreadyConnected = errors.New("Connect() or ConnectTLS() has already been called")
errAlreadyAsync = errors.New("Async() has already been called")
)
// UnknownReplyError records the sentence whose Word is unknown.
type UnknownReplyError struct {
Sentence *proto.Sentence
}
func (err *UnknownReplyError) Error() string {
return fmt.Sprintf("unknown RouterOS reply word: %s", err.Sentence.Word)
}
// DeviceError records the sentence containing the error received from the device.
// The sentence may have Word !trap or !fatal.
type DeviceError struct {
Sentence *proto.Sentence
}
func (err *DeviceError) Error() string {
m := err.Sentence.Map["message"]
if m == "" {
m = fmt.Sprintf("unknown error: %s", err.Sentence)
}
return fmt.Sprintf("RouterOS: %s", m)
}