errors

package
v0.0.0-...-bb7c920 Latest Latest
Warning

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

Go to latest
Published: May 29, 2019 License: MIT Imports: 2 Imported by: 3

Documentation

Overview

Package errors holds the HTTP errors that the API returns.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrAlreadyExists = New(
		http.StatusConflict,
		"AlreadyExists",
		"entry already exists")
	ErrInternal = New(
		http.StatusInternalServerError,
		"Internal",
		http.StatusText(http.StatusInternalServerError))
	ErrUnauthorized = New(
		http.StatusUnauthorized,
		"Unauthorized",
		http.StatusText(http.StatusUnauthorized))
	ErrForbiden = New(
		http.StatusForbidden,
		"Forbiden",
		http.StatusText(http.StatusForbidden))
	ErrNotFound = New(
		http.StatusNotFound,
		"NotFound",
		http.StatusText(http.StatusNotFound))
	ErrBadRequest = New(
		http.StatusBadRequest,
		"BadRequest",
		http.StatusText(http.StatusBadRequest))
	ErrUnprocessable = New(
		http.StatusUnprocessableEntity,
		"UnprocessableEntity",
		http.StatusText(http.StatusUnprocessableEntity))
	ErrUnsupportedMediaType = New(
		http.StatusUnsupportedMediaType,
		"UnsupportedMediaType",
		http.StatusText(http.StatusUnsupportedMediaType))
)

Functions

This section is empty.

Types

type Error

type Error struct {
	Status  int    `json:"status,omitempty"`
	Type    string `json:"type"`
	Message string `json:"message"`
}

Error holds the basic error struct.

func New

func New(s int, t, m string) *Error

New creates and returns an error based on the provided status, type and message.

func (*Error) Error

func (e *Error) Error() string

Error implements the error interface.

type MultiError

type MultiError struct {
	Status  int     `json:"status,omitempty"`
	Type    string  `json:"type"`
	Message string  `json:"message"`
	Errors  []Error `json:"errors,omitempty"`
}

MultiError holds nested errors.

func NewMultiError

func NewMultiError(s int, t, m string, errs []Error) *MultiError

NewMultiError creates and returns an error with multiple nested errors.

func (*MultiError) Error

func (e *MultiError) Error() string

Error implements the error interface.

Jump to

Keyboard shortcuts

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