Documentation
¶
Overview ¶
Package errors provides custom error types and utilities for the REST client.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ErrNotFound indicates a resource was not found. ErrNotFound = errors.New("not found") // ErrInvalidInput indicates invalid user input. ErrInvalidInput = errors.New("invalid input") // ErrTimeout indicates an operation timed out. ErrTimeout = errors.New("operation timed out") // ErrCanceled indicates an operation was canceled. ErrCanceled = errors.New("operation canceled") // ErrAuth indicates an authentication failure. ErrAuth = errors.New("authentication failed") // ErrNetwork indicates a network-related error. ErrNetwork = errors.New("network error") // ErrParse indicates a parsing error. ErrParse = errors.New("parse error") // ErrScript indicates a script execution error. ErrScript = errors.New("script error") // ErrConfig indicates a configuration error. ErrConfig = errors.New("configuration error") // ErrFileSystem indicates a file system error. ErrFileSystem = errors.New("file system error") )
Sentinel errors that can be checked with errors.Is()
Functions ¶
func As ¶
As finds the first error in err's chain that matches target. This is a convenience re-export of errors.As.
func Is ¶
Is reports whether any error in err's chain matches target. This is a convenience re-export of errors.Is.
Types ¶
type ParseError ¶
type ParseError struct {
File string // File being parsed
Line int // Line number where error occurred (0 if unknown)
Message string // Error message
Wrapped error // Underlying error, if any
}
ParseError represents an error that occurred during parsing.
func NewParseError ¶
func NewParseError(file string, line int, message string) *ParseError
NewParseError creates a new ParseError.
func NewParseErrorWithCause ¶
func NewParseErrorWithCause(file string, line int, message string, cause error) *ParseError
NewParseErrorWithCause creates a new ParseError with an underlying cause.
func (*ParseError) Error ¶
func (e *ParseError) Error() string
func (*ParseError) Is ¶
func (e *ParseError) Is(target error) bool
Is implements errors.Is for ParseError.
func (*ParseError) Unwrap ¶
func (e *ParseError) Unwrap() error
type RequestError ¶
type RequestError struct {
Op string // Operation that failed (e.g., "send", "build", "parse")
URL string // URL of the request, if applicable
Method string // HTTP method, if applicable
Wrapped error // Underlying error
}
RequestError represents an error that occurred during HTTP request processing.
func NewRequestError ¶
func NewRequestError(op string, err error) *RequestError
NewRequestError creates a new RequestError.
func NewRequestErrorWithURL ¶
func NewRequestErrorWithURL(op, method, url string, err error) *RequestError
NewRequestErrorWithURL creates a new RequestError with URL context.
func (*RequestError) Error ¶
func (e *RequestError) Error() string
func (*RequestError) Unwrap ¶
func (e *RequestError) Unwrap() error
type ScriptError ¶
type ScriptError struct {
Script string // Script name or phase (e.g., "pre-request", "post-response")
Message string // Error message
Wrapped error // Underlying error
}
ScriptError represents an error from script execution.
func NewScriptError ¶
func NewScriptError(script, message string) *ScriptError
NewScriptError creates a new ScriptError.
func NewScriptErrorWithCause ¶
func NewScriptErrorWithCause(script, message string, cause error) *ScriptError
NewScriptErrorWithCause creates a new ScriptError with an underlying cause.
func (*ScriptError) Error ¶
func (e *ScriptError) Error() string
func (*ScriptError) Is ¶
func (e *ScriptError) Is(target error) bool
Is implements errors.Is for ScriptError.
func (*ScriptError) Unwrap ¶
func (e *ScriptError) Unwrap() error
type ValidationError ¶
type ValidationError struct {
Field string // Field that failed validation
Value string // The invalid value (may be redacted for sensitive fields)
Message string // Description of what's wrong
}
ValidationError represents a validation error.
func NewValidationError ¶
func NewValidationError(field, message string) *ValidationError
NewValidationError creates a new ValidationError.
func NewValidationErrorWithValue ¶
func NewValidationErrorWithValue(field, value, message string) *ValidationError
NewValidationErrorWithValue creates a new ValidationError with the invalid value.
func (*ValidationError) Error ¶
func (e *ValidationError) Error() string
func (*ValidationError) Is ¶
func (e *ValidationError) Is(target error) bool
Is implements errors.Is for ValidationError.