errs

package
v0.0.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 12, 2025 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Log

func Log(ctx context.Context, err error)

func LogWithLogger

func LogWithLogger(logger *slog.Logger, ctx context.Context, err error)

func NewApiError

func NewApiError(httpResp *http.Response, err error) error

func NewCommandError

func NewCommandError(commandName string, err error) error

func NewToolError

func NewToolError(toolName string, err error) error

Types

type ApiError

type ApiError struct {
	// OriginalError is the underlying error that occurred
	OriginalError error
	// StatusCode is the HTTP status code from the response (e.g., 404, 500)
	StatusCode int
	// Status is the HTTP status text (e.g., "Not Found", "Internal Server Error")
	Status string
	// Method is the HTTP method used in the request (e.g., "GET", "POST")
	Method string
	// URL is the full URL of the request that caused the error
	URL string
	// ResponseBody contains the raw response body from the API
	ResponseBody string
}

ApiError represents a structured API error with HTTP response details. It wraps the original error and enriches it with HTTP context including status codes, request methods, and URLs for better debugging and logging.

ApiError implements the error interface and supports error unwrapping, allowing it to integrate with Go's standard error handling patterns.

func (*ApiError) Error

func (e *ApiError) Error() string

func (*ApiError) Unwrap

func (e *ApiError) Unwrap() error

type CommandError

type CommandError struct {
	CommandName   string
	OriginalError error
}

CommandError represents an error that occurred within a specific cobra command

func (*CommandError) Error

func (e *CommandError) Error() string

func (*CommandError) Unwrap

func (e *CommandError) Unwrap() error

type ToolError

type ToolError struct {
	ToolName      string
	OriginalError error
}

ToolError represents an error that occurred within a specific tool

func (*ToolError) Error

func (e *ToolError) Error() string

func (*ToolError) Unwrap

func (e *ToolError) Unwrap() error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL