Documentation
¶
Index ¶
- type Code
- type Error
- func AlreadyExists(resource string, kv ...interface{}) *Error
- func FailedPrecondition(msg string, kv ...interface{}) *Error
- func Internal(err error, kv ...interface{}) *Error
- func InvalidArg(msg string, kv ...interface{}) *Error
- func New(code Code, message string, cause error, kv ...interface{}) *Error
- func NotFound(resource string, kv ...interface{}) *Error
- func Unsupported(msg string, kv ...interface{}) *Error
- func Wrap(code Code, err error, kv ...interface{}) *Error
- type MCPErrorCode
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Code ¶
type Code string
Code represents canonical error codes for MCP operations
const ( // INVALID_ARGUMENT indicates client-provided argument is invalid CodeInvalidArgument Code = "INVALID_ARGUMENT" // NOT_FOUND indicates requested resource was not found CodeNotFound Code = "NOT_FOUND" // ALREADY_EXISTS indicates resource already exists CodeAlreadyExists Code = "ALREADY_EXISTS" // PERMISSION_DENIED indicates client lacks permission CodePermissionDenied Code = "PERMISSION_DENIED" // UNAUTHENTICATED indicates client authentication failed CodeUnauthenticated Code = "UNAUTHENTICATED" // FAILED_PRECONDITION indicates operation precondition not met CodeFailedPrecondition Code = "FAILED_PRECONDITION" // INTERNAL indicates server internal error CodeInternal Code = "INTERNAL" CodeUnavailable Code = "UNAVAILABLE" // UNSUPPORTED indicates operation not supported CodeUnsupported Code = "UNSUPPORTED" // CONFLICT indicates resource conflict CodeConflict Code = "CONFLICT" )
type Error ¶
type Error struct {
// contains filtered or unexported fields
}
Error represents a typed error with code, message, and optional key-value context
func AlreadyExists ¶
AlreadyExists creates an ALREADY_EXISTS error with optional key-value context
func FailedPrecondition ¶
FailedPrecondition creates a FAILED_PRECONDITION error with optional key-value context
func Internal ¶
Internal creates an INTERNAL error, optionally wrapping another error, with key-value context
func InvalidArg ¶
InvalidArg creates an INVALID_ARGUMENT error with optional key-value context
func NotFound ¶
NotFound creates a NOT_FOUND error for a specific resource with optional key-value context
func Unsupported ¶
Unsupported creates an UNSUPPORTED error with optional key-value context
func Wrap ¶
Wrap creates an error with the specified code, wrapping another error, with key-value context
func (*Error) Error ¶
Error implements the error interface with JSON-safe output for backwards compatibility
type MCPErrorCode ¶
type MCPErrorCode int
MCPErrorCode represents MCP protocol error codes
const ( // MCP protocol error codes based on JSON-RPC 2.0 spec MCPErrorInvalidRequest MCPErrorCode = -32600 MCPErrorMethodNotFound MCPErrorCode = -32601 MCPErrorInvalidParams MCPErrorCode = -32602 MCPErrorInternalError MCPErrorCode = -32603 MCPErrorParseError MCPErrorCode = -32700 // MCP-specific error codes MCPErrorNotFound MCPErrorCode = -32001 MCPErrorConflict MCPErrorCode = -32002 MCPErrorUnsupported MCPErrorCode = -32004 MCPErrorPermissionDenied MCPErrorCode = -32005 MCPErrorUnauthenticated MCPErrorCode = -32006 )
func ToMCPError ¶
func ToMCPError(err error) (MCPErrorCode, string)
ToMCPError translates a typed error to MCP error code and message