errors

package
v0.0.0-...-357839d Latest Latest
Warning

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

Go to latest
Published: May 27, 2021 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

View Source
const (
	//ProblemReportContentType as required by https://tools.ietf.org/html/rfc7807
	ProblemReportContentType string = "application/problem+json"
)

Variables

This section is empty.

Functions

func ReportNewBadRequestData

func ReportNewBadRequestData(w http.ResponseWriter, detail string)

ReportNewBadRequestData creates a BadRequestData instance and sends it to the supplied http.ResponseWriter

func ReportNewInternalError

func ReportNewInternalError(w http.ResponseWriter, detail string)

ReportNewInternalError creates an InternalError instance and sends it to the supplied http.ResponseWriter

func ReportNewInvalidRequest

func ReportNewInvalidRequest(w http.ResponseWriter, detail string)

ReportNewInvalidRequest creates an InvalidRequest instance and sends it to the supplied http.ResponseWriter

Types

type BadRequestData

type BadRequestData struct {
	ProblemDetailsImpl
}

BadRequestData reports that the request includes input data which does not meet the requirements of the operation

func NewBadRequestData

func NewBadRequestData(detail string) *BadRequestData

NewBadRequestData creates and returns a new instance of a BadRequestData with the supplied problem detail

type InternalError

type InternalError struct {
	ProblemDetailsImpl
}

InternalError reports that there has been an error during the operation execution

func NewInternalError

func NewInternalError(detail string) *InternalError

NewInternalError creates and returns a new instance of an InternalError with the supplied problem detail

type InvalidRequest

type InvalidRequest struct {
	ProblemDetailsImpl
}

InvalidRequest reports that the request associated to the operation is syntactically invalid or includes wrong content

func NewInvalidRequest

func NewInvalidRequest(detail string) *InvalidRequest

NewInvalidRequest creates and returns a new instance of an InvalidRequest with the supplied problem detail

type ProblemDetails

type ProblemDetails interface {
	ContentType() string
	Type() string
	Title() string
	Detail() string
	MarshalJSON() ([]byte, error)
	WriteResponse(w http.ResponseWriter)
}

ProblemDetails stores details about a certain problem according to RFC7807 See https://tools.ietf.org/html/rfc7807

type ProblemDetailsImpl

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

ProblemDetailsImpl is an implementation of the ProblemDetails interface

func (*ProblemDetailsImpl) ContentType

func (p *ProblemDetailsImpl) ContentType() string

ContentType returns the ContentType to be used when returning this problem

func (*ProblemDetailsImpl) MarshalJSON

func (p *ProblemDetailsImpl) MarshalJSON() ([]byte, error)

MarshalJSON is called when a ProblemDetailsImpl instance should be serialized to JSON

func (*ProblemDetailsImpl) ResponseCode

func (p *ProblemDetailsImpl) ResponseCode() int

ResponseCode returns the HTTP response code to be used when returning a specific problem

func (*ProblemDetailsImpl) WriteResponse

func (p *ProblemDetailsImpl) WriteResponse(w http.ResponseWriter)

WriteResponse writes the contents of this instance to a http.ResponseWriter

Jump to

Keyboard shortcuts

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