From 46244458c44ff96e92a7a8cd17b69716aa3ff88a Mon Sep 17 00:00:00 2001 From: duwenxin Date: Mon, 2 Feb 2026 13:20:39 -0500 Subject: [PATCH] add error code --- internal/util/errors.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/internal/util/errors.go b/internal/util/errors.go index 74dae31d3d..e37615a457 100644 --- a/internal/util/errors.go +++ b/internal/util/errors.go @@ -27,7 +27,7 @@ type ToolboxError interface { Category() ErrorCategory } -// Agent Errors +// Agent Errors return 200 to the sender type AgentError struct { Msg string Cause error @@ -43,9 +43,10 @@ func NewAgentError(msg string, args ...any) *AgentError { return &AgentError{Msg: fmt.Sprintf(msg, args...)} } -// Server Errors +// Server Errors return specified error code type ServerError struct { Msg string + Code int Cause error } @@ -55,6 +56,6 @@ func (e *ServerError) Category() ErrorCategory { return CategoryServer } func (e *ServerError) Unwrap() error { return e.Cause } -func NewServerError(msg string, cause error) *ServerError { - return &ServerError{Msg: msg, Cause: cause} +func NewServerError(msg string, code int, cause error) *ServerError { + return &ServerError{Msg: msg, Code: code, Cause: cause} }