ogenerrors

package
v0.0.0-...-cdf09a4 Latest Latest
Warning

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

Go to latest
Published: Dec 25, 2023 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package ogenerrors contains ogen errors type definitions and helpers.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrSecurityRequirementIsNotSatisfied is returned when security requirement is not satisfied.
	ErrSecurityRequirementIsNotSatisfied = errors.New("security requirement is not satisfied")
	// ErrSkipClientSecurity is guard error to exclude security scheme from client request.
	ErrSkipClientSecurity = errors.New("skip client security")
	// ErrSkipServerSecurity is guard error to exclude security scheme from server request.
	ErrSkipServerSecurity = errors.New("skip server security")
)

Functions

func DefaultErrorHandler

func DefaultErrorHandler(ctx context.Context, w http.ResponseWriter, r *http.Request, err error)

DefaultErrorHandler is the default error handler.

func ErrorCode

func ErrorCode(err error) (code int)

ErrorCode returns HTTP code for given error.

The default code is http.StatusInternalServerError.

Types

type DecodeBodyError

type DecodeBodyError struct {
	ContentType string
	Body        []byte
	Err         error
}

DecodeBodyError occurs when request or response body cannot be decoded.

func (*DecodeBodyError) Error

func (d *DecodeBodyError) Error() string

Error implements error.

func (*DecodeBodyError) Format

func (d *DecodeBodyError) Format(s fmt.State, verb rune)

Format implements fmt.Formatter.

func (*DecodeBodyError) FormatError

func (d *DecodeBodyError) FormatError(p errors.Printer) (next error)

FormatError implements errors.Formatter.

func (*DecodeBodyError) Unwrap

func (d *DecodeBodyError) Unwrap() error

Unwrap returns child error.

type DecodeParamError

type DecodeParamError struct {
	Name string
	In   openapi.ParameterLocation
	Err  error
}

DecodeParamError reports that error caused by parameter decoder.

func (*DecodeParamError) Error

func (d *DecodeParamError) Error() string

Error implements error.

func (*DecodeParamError) Format

func (d *DecodeParamError) Format(s fmt.State, verb rune)

Format implements fmt.Formatter.

func (*DecodeParamError) FormatError

func (d *DecodeParamError) FormatError(p errors.Printer) (next error)

FormatError implements errors.Formatter.

func (*DecodeParamError) Unwrap

func (d *DecodeParamError) Unwrap() error

Unwrap returns child error.

type DecodeParamsError

type DecodeParamsError struct {
	OperationContext
	Err error
}

DecodeParamsError reports that error caused by params decoder.

func (*DecodeParamsError) Code

func (d *DecodeParamsError) Code() int

Code returns http code to respond.

func (*DecodeParamsError) Error

func (d *DecodeParamsError) Error() string

Error implements error.

func (*DecodeParamsError) Format

func (d *DecodeParamsError) Format(s fmt.State, verb rune)

Format implements fmt.Formatter.

func (*DecodeParamsError) FormatError

func (d *DecodeParamsError) FormatError(p errors.Printer) (next error)

FormatError implements errors.Formatter.

func (*DecodeParamsError) Unwrap

func (d *DecodeParamsError) Unwrap() error

Unwrap returns child error.

type DecodeRequestError

type DecodeRequestError struct {
	OperationContext
	Err error
}

DecodeRequestError reports that error caused by request decoder.

func (*DecodeRequestError) Code

func (d *DecodeRequestError) Code() int

Code returns http code to respond.

func (*DecodeRequestError) Error

func (d *DecodeRequestError) Error() string

Error implements error.

func (*DecodeRequestError) Format

func (d *DecodeRequestError) Format(s fmt.State, verb rune)

Format implements fmt.Formatter.

func (*DecodeRequestError) FormatError

func (d *DecodeRequestError) FormatError(p errors.Printer) (next error)

FormatError implements errors.Formatter.

func (*DecodeRequestError) Unwrap

func (d *DecodeRequestError) Unwrap() error

Unwrap returns child error.

type Error

type Error interface {
	OperationName() string
	OperationID() string
	Code() int
	errors.Wrapper
	errors.Formatter
	fmt.Formatter
	error
}

Error is an ogen error.

type ErrorHandler

type ErrorHandler func(ctx context.Context, w http.ResponseWriter, r *http.Request, err error)

ErrorHandler is an error handler.

type OperationContext

type OperationContext struct {
	Name string
	ID   string
}

OperationContext defines operation context for the error.

func (OperationContext) OperationID

func (d OperationContext) OperationID() string

OperationID returns operation ID.

func (OperationContext) OperationName

func (d OperationContext) OperationName() string

OperationName returns operation Name.

type SecurityError

type SecurityError struct {
	OperationContext
	Security string
	Err      error
}

SecurityError reports that error caused by security handler.

func (*SecurityError) Code

func (d *SecurityError) Code() int

Code returns http code to respond.

func (*SecurityError) Error

func (d *SecurityError) Error() string

Error implements error.

func (*SecurityError) Format

func (d *SecurityError) Format(s fmt.State, verb rune)

Format implements fmt.Formatter.

func (*SecurityError) FormatError

func (d *SecurityError) FormatError(p errors.Printer) (next error)

FormatError implements errors.Formatter.

func (*SecurityError) Unwrap

func (d *SecurityError) Unwrap() error

Unwrap returns child error.

Jump to

Keyboard shortcuts

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