errors

package
v0.0.0-...-bcd07de Latest Latest
Warning

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

Go to latest
Published: Jun 20, 2022 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ErrorToJSON

func ErrorToJSON(e HTTPError, w *io.Writer) error

ErrorToJSON converts an error type to JSON and writes to provided writer

Types

type BadRequest

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

BadRequest - HTTP error for 400 error code

func (*BadRequest) StatusCode

func (e *BadRequest) StatusCode() int

func (*BadRequest) StatusMessage

func (e *BadRequest) StatusMessage() string

func (*BadRequest) ToJSON

func (e *BadRequest) ToJSON(w io.Writer) error

type HTTPError

type HTTPError interface {
	StatusCode() int
	StatusMessage() string
	ToJSON(io.Writer) error

	error
	// contains filtered or unexported methods
}

HTTPError is the universal interface for all HTTPError 's it includes their StatusCode() and a StatusMessage() which contains a short description of the error

type InternalServerError

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

InternalServerError - HTTP error for 500 error code

func (InternalServerError) StatusCode

func (InternalServerError) StatusCode() int

StatusCode is 500 for unimplemented error status codes

func (InternalServerError) StatusMessage

func (g InternalServerError) StatusMessage() string

StatusMessage looks up the already defined map[int]string from the http package containing maps of common http errors and their texts

func (InternalServerError) ToJSON

func (g InternalServerError) ToJSON(w io.Writer) error

ToJSON is the default implementation for converting an error type to JSON to be sent in the response body

type NotFound

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

NotFound - HTTP error for 404 error code

func (NotFound) StatusCode

func (e NotFound) StatusCode() int

func (NotFound) StatusMessage

func (e NotFound) StatusMessage() string

func (NotFound) ToJSON

func (e NotFound) ToJSON(w io.Writer) error

Jump to

Keyboard shortcuts

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