forked from dlorenc/multiclaude
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patherrors.go
More file actions
68 lines (56 loc) · 1.87 KB
/
errors.go
File metadata and controls
68 lines (56 loc) · 1.87 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
package tmux
import "fmt"
// SessionNotFoundError indicates that a tmux session does not exist.
type SessionNotFoundError struct {
Name string
}
func (e *SessionNotFoundError) Error() string {
return fmt.Sprintf("tmux session not found: %s", e.Name)
}
// Is returns true if target is a *SessionNotFoundError.
func (e *SessionNotFoundError) Is(target error) bool {
_, ok := target.(*SessionNotFoundError)
return ok
}
// WindowNotFoundError indicates that a tmux window does not exist within a session.
type WindowNotFoundError struct {
Session string
Window string
}
func (e *WindowNotFoundError) Error() string {
return fmt.Sprintf("tmux window not found: %s in session %s", e.Window, e.Session)
}
// Is returns true if target is a *WindowNotFoundError.
func (e *WindowNotFoundError) Is(target error) bool {
_, ok := target.(*WindowNotFoundError)
return ok
}
// CommandError wraps errors from tmux command execution with additional context.
type CommandError struct {
Op string // Operation that failed (e.g., "create-session", "send-keys")
Session string // Session name, if applicable
Window string // Window name, if applicable
Err error // Underlying error
}
func (e *CommandError) Error() string {
if e.Window != "" {
return fmt.Sprintf("tmux %s failed for %s:%s: %v", e.Op, e.Session, e.Window, e.Err)
}
if e.Session != "" {
return fmt.Sprintf("tmux %s failed for session %s: %v", e.Op, e.Session, e.Err)
}
return fmt.Sprintf("tmux %s failed: %v", e.Op, e.Err)
}
func (e *CommandError) Unwrap() error {
return e.Err
}
// IsSessionNotFound returns true if the error indicates a session was not found.
func IsSessionNotFound(err error) bool {
_, ok := err.(*SessionNotFoundError)
return ok
}
// IsWindowNotFound returns true if the error indicates a window was not found.
func IsWindowNotFound(err error) bool {
_, ok := err.(*WindowNotFoundError)
return ok
}