common

package
v0.0.0-...-ab77271 Latest Latest
Warning

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

Go to latest
Published: Jul 23, 2018 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNotFound is an error associated with a 404 response
	ErrNotFound = &ApiError{http.StatusNotFound, "resource not found"}
	// ErrConflict is an error associated with a 409 response
	ErrConflict = &ApiError{http.StatusConflict, "duplicate resource id"}
	// ErrInternalServerError is an error associated with a 500 response
	ErrInternalServerError = &ApiError{http.StatusInternalServerError, "internal server error"}
	// ErrBadRequest returned when user submits an invalid request
	ErrBadRequest = &ApiError{http.StatusBadRequest, "bad request"}
)

Functions

This section is empty.

Types

type ApiError

type ApiError struct {
	Status  int
	Message string
}

ApiError contains advanced information about an error, like a return status code to the desired action

func NewApiError

func NewApiError(status int, message string) *ApiError

NewApiError creates a new API error

func (*ApiError) Code

func (e *ApiError) Code() int

Status returns the status code associated with this error

func (*ApiError) Error

func (e *ApiError) Error() string

Error returns an error message

Jump to

Keyboard shortcuts

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