-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy patherrors.go
More file actions
62 lines (49 loc) · 1.25 KB
/
Copy patherrors.go
File metadata and controls
62 lines (49 loc) · 1.25 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
package main
import "fmt"
// Error types for different categories of errors
type (
// BirdError represents errors from BIRD daemon communication
BirdError struct {
Operation string
Err error
}
// SNMPError represents errors from SNMP operations
SNMPError struct {
Operation string
Err error
}
// ParseError represents errors from parsing BIRD output
ParseError struct {
Input string
Err error
}
)
// Error implementations
func (e *BirdError) Error() string {
return fmt.Sprintf("bird error during %s: %v", e.Operation, e.Err)
}
func (e *BirdError) Unwrap() error {
return e.Err
}
func (e *SNMPError) Error() string {
return fmt.Sprintf("snmp error during %s: %v", e.Operation, e.Err)
}
func (e *SNMPError) Unwrap() error {
return e.Err
}
func (e *ParseError) Error() string {
return fmt.Sprintf("parse error for input '%s': %v", e.Input, e.Err)
}
func (e *ParseError) Unwrap() error {
return e.Err
}
// Helper functions to create errors
func newBirdError(op string, err error) error {
return &BirdError{Operation: op, Err: err}
}
func newSNMPError(op string, err error) error {
return &SNMPError{Operation: op, Err: err}
}
func newParseError(input string, err error) error {
return &ParseError{Input: input, Err: err}
}