add error formatting

This commit is contained in:
duwenxin99
2026-02-04 16:23:54 -05:00
parent 7bc0575303
commit 6cc5470f5e

View File

@@ -44,7 +44,12 @@ type AgentError struct {
var _ ToolboxError = &AgentError{}
func (e *AgentError) Error() string { return e.Msg }
func (e *AgentError) Error() string {
if e.Cause != nil {
return fmt.Sprintf("%s: %v", e.Msg, e.Cause)
}
return e.Msg
}
func (e *AgentError) Category() ErrorCategory { return CategoryAgent }
@@ -63,7 +68,12 @@ type ClientServerError struct {
var _ ToolboxError = &ClientServerError{}
func (e *ClientServerError) Error() string { return fmt.Sprintf("%s: %v", e.Msg, e.Cause) }
func (e *ClientServerError) Error() string {
if e.Cause != nil {
return fmt.Sprintf("%s: %v", e.Msg, e.Cause)
}
return e.Msg
}
func (e *ClientServerError) Category() ErrorCategory { return CategoryServer }