forked from k-sone/snmpgo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patherrors.go
37 lines (30 loc) · 830 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
37
package snmpgo
import (
"errors"
"fmt"
)
var UnsupportedOperation error = errors.New("Unsupported operation")
// An ArgumentError suggests that the arguments are wrong
type ArgumentError struct {
Value interface{} // Argument that has a problem
Message string // Error message
}
func (e *ArgumentError) Error() string {
return fmt.Sprintf("%s, value `%v`", e.Message, e.Value)
}
// A MessageError suggests that the received message is wrong or is not obtained
type MessageError struct {
Cause error // Cause of the error
Message string // Error message
Detail string // Detail of the error for debugging
}
func (e *MessageError) Error() string {
if e.Cause == nil {
return e.Message
} else {
return fmt.Sprintf("%s, cause `%v`", e.Message, e.Cause)
}
}
type notInTimeWindowError struct {
error
}