mirror of
https://github.com/googleapis/genai-toolbox.git
synced 2026-02-02 19:24:59 -05:00
add error code
This commit is contained in:
@@ -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}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user