-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patherrors.go
More file actions
61 lines (48 loc) · 1.54 KB
/
errors.go
File metadata and controls
61 lines (48 loc) · 1.54 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
package neko
import "fmt"
// AgentError is the base error type for agent errors.
type AgentError struct {
Message string
Cause error
}
func (e *AgentError) Error() string {
if e.Cause != nil {
return fmt.Sprintf("%s: %v", e.Message, e.Cause)
}
return e.Message
}
func (e *AgentError) Unwrap() error { return e.Cause }
// Specific error types
// ErrMaxSteps indicates the agent exceeded maximum steps.
type ErrMaxSteps struct{ AgentError }
// NewErrMaxSteps creates a max steps error.
func NewErrMaxSteps(maxSteps int) *ErrMaxSteps {
return &ErrMaxSteps{AgentError{Message: fmt.Sprintf("exceeded max steps: %d", maxSteps)}}
}
// ErrParsing indicates a parsing failure.
type ErrParsing struct{ AgentError }
// NewErrParsing creates a parsing error.
func NewErrParsing(msg string, cause error) *ErrParsing {
return &ErrParsing{AgentError{Message: msg, Cause: cause}}
}
// ErrToolExecution indicates a tool execution failure.
type ErrToolExecution struct {
AgentError
ToolName string
}
// NewErrToolExecution creates a tool execution error.
func NewErrToolExecution(toolName string, cause error) *ErrToolExecution {
return &ErrToolExecution{
AgentError: AgentError{
Message: fmt.Sprintf("tool '%s' execution failed", toolName),
Cause: cause,
},
ToolName: toolName,
}
}
// ErrGeneration indicates an LLM generation failure.
type ErrGeneration struct{ AgentError }
// NewErrGeneration creates a generation error.
func NewErrGeneration(msg string, cause error) *ErrGeneration {
return &ErrGeneration{AgentError{Message: msg, Cause: cause}}
}