problemDetails

package
v0.0.0-...-52d9df3 Latest Latest
Warning

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

Go to latest
Published: May 13, 2024 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ContentTypeJSON = "application_exceptions/problem+json"
)

Variables

This section is empty.

Functions

func Map

func Map[E error](problem ProblemDetailFunc[E])

func WriteTo

func WriteTo(p ProblemDetailErr, w http.ResponseWriter) (int, error)

WriteTo writes the JSON Problem to an HTTP Response Writer

Types

type OptionBuilder

type OptionBuilder struct {
	// contains filtered or unexported fields
}

func NewOptionBuilder

func NewOptionBuilder() *OptionBuilder

func (*OptionBuilder) Build

func (p *OptionBuilder) Build() map[reflect.Type]func(err error) ProblemDetailErr

func (*OptionBuilder) Map

func (p *OptionBuilder) Map(srcErrorType reflect.Type, problem ProblemDetailFunc[error]) *OptionBuilder

type ProblemDetailErr

type ProblemDetailErr interface {
	GetStatus() int
	SetStatus(status int) ProblemDetailErr
	GetTitle() string
	SetTitle(title string) ProblemDetailErr
	GetStackTrace() string
	SetStackTrace(stackTrace string) ProblemDetailErr
	GetDetail() string
	SetDetail(detail string) ProblemDetailErr
	GetType() string
	SetType(typ string) ProblemDetailErr
	Error() string
	ErrBody() error
}

ProblemDetailErr ProblemDetail error interface

func NewApiProblemDetail

func NewApiProblemDetail(status int, detail string, stackTrace string) ProblemDetailErr

func NewApplicationProblemDetail

func NewApplicationProblemDetail(status int, detail string, stackTrace string) ProblemDetailErr

func NewBadRequestProblemDetail

func NewBadRequestProblemDetail(detail string, stackTrace string) ProblemDetailErr

func NewConflictProblemDetail

func NewConflictProblemDetail(detail string, stackTrace string) ProblemDetailErr

func NewDomainProblemDetail

func NewDomainProblemDetail(status int, detail string, stackTrace string) ProblemDetailErr

func NewForbiddenProblemDetail

func NewForbiddenProblemDetail(detail string, stackTrace string) ProblemDetailErr

func NewInternalServerProblemDetail

func NewInternalServerProblemDetail(detail string, stackTrace string) ProblemDetailErr

func NewNotFoundErrorProblemDetail

func NewNotFoundErrorProblemDetail(detail string, stackTrace string) ProblemDetailErr

func NewProblemDetail

func NewProblemDetail(status int, title string, detail string, stackTrace string) ProblemDetailErr

NewProblemDetail New ProblemDetail Error

func NewProblemDetailFromCode

func NewProblemDetailFromCode(status int, stackTrace string) ProblemDetailErr

NewProblemDetailFromCode New ProblemDetail Error With Message

func NewProblemDetailFromCodeAndDetail

func NewProblemDetailFromCodeAndDetail(
	status int,
	detail string,
	stackTrace string,
) ProblemDetailErr

NewProblemDetailFromCodeAndDetail New ProblemDetail Error With Message

func NewUnAuthorizedErrorProblemDetail

func NewUnAuthorizedErrorProblemDetail(detail string, stackTrace string) ProblemDetailErr

func NewValidationProblemDetail

func NewValidationProblemDetail(detail string, stackTrace string) ProblemDetailErr

func ParseError

func ParseError(err error) ProblemDetailErr

func ResolveProblemDetail

func ResolveProblemDetail(err error) ProblemDetailErr

type ProblemDetailFunc

type ProblemDetailFunc[E error] func(err E) ProblemDetailErr

type ProblemDetailParser

type ProblemDetailParser struct {
	// contains filtered or unexported fields
}

func NewProblemDetailParser

func NewProblemDetailParser(builder func(builder *OptionBuilder)) *ProblemDetailParser

func (*ProblemDetailParser) ResolveError

func (p *ProblemDetailParser) ResolveError(err error) ProblemDetailErr

Jump to

Keyboard shortcuts

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