-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patherrors.go
More file actions
74 lines (62 loc) · 1.75 KB
/
Copy patherrors.go
File metadata and controls
74 lines (62 loc) · 1.75 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 modelsocket
import (
"errors"
"fmt"
)
// Sentinel errors for common conditions.
var (
ErrClosed = errors.New("modelsocket: connection closed")
ErrSeqClosed = errors.New("modelsocket: sequence closed")
ErrTimeout = errors.New("modelsocket: operation timed out")
ErrInvalidState = errors.New("modelsocket: invalid sequence state")
ErrToolNotFound = errors.New("modelsocket: tool not found")
ErrUnexpectedEvent = errors.New("modelsocket: unexpected event")
ErrBufferFull = errors.New("modelsocket: buffer full")
)
// ConnectionError represents a connection-level error.
type ConnectionError struct {
Op string
URL string
Err error
}
func (e *ConnectionError) Error() string {
if e.URL != "" {
return fmt.Sprintf("modelsocket: %s %s: %v", e.Op, e.URL, e.Err)
}
return fmt.Sprintf("modelsocket: %s: %v", e.Op, e.Err)
}
func (e *ConnectionError) Unwrap() error {
return e.Err
}
// SendError represents an error during request sending.
type SendError struct {
Op string
Err error
}
func (e *SendError) Error() string {
return fmt.Sprintf("modelsocket: send %s: %v", e.Op, e.Err)
}
func (e *SendError) Unwrap() error {
return e.Err
}
// ProtocolError represents a protocol-level error from the server.
type ProtocolError struct {
Code string
Message string
SeqID string
CID string
}
func (e *ProtocolError) Error() string {
if e.Code != "" {
return fmt.Sprintf("modelsocket: protocol error [%s]: %s", e.Code, e.Message)
}
return fmt.Sprintf("modelsocket: protocol error: %s", e.Message)
}
// SeqError represents a sequence-level error.
type SeqError struct {
SeqID string
Message string
}
func (e *SeqError) Error() string {
return fmt.Sprintf("modelsocket: sequence %s: %s", e.SeqID, e.Message)
}