mirror of
https://github.com/nshttpd/mikrotik-exporter.git
synced 2024-12-12 14:26:51 +01:00
36 lines
827 B
Go
36 lines
827 B
Go
package routeros
|
|
|
|
import (
|
|
"errors"
|
|
|
|
"gopkg.in/routeros.v2/proto"
|
|
)
|
|
|
|
var (
|
|
errAlreadyAsync = errors.New("Async() has already been called")
|
|
errAsyncLoopEnded = errors.New("Async() loop has ended - probably read error")
|
|
)
|
|
|
|
// UnknownReplyError records the sentence whose Word is unknown.
|
|
type UnknownReplyError struct {
|
|
Sentence *proto.Sentence
|
|
}
|
|
|
|
func (err *UnknownReplyError) Error() string {
|
|
return "unknown RouterOS reply word: " + 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 = "unknown error: " + err.Sentence.String()
|
|
}
|
|
return "from RouterOS device: " + m
|
|
}
|