errors

package
v0.1.6 Latest Latest
Warning

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

Go to latest
Published: Oct 9, 2019 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BadRequest

func BadRequest(detail string) error

BadRequest generates a 400 error.

func Conflict

func Conflict(detail string) error

Conflict generates a 409 error.

func Forbidden

func Forbidden(detail string) error

Forbidden generates a 403 error.

func InternalServerError

func InternalServerError(detail string) error

InternalServerError generates a 500 error.

func New

func New(detail string, code int32) error

New generates a custom error.

func NotFound

func NotFound(detail string) error

NotFound generates a 404 error.

func Unauthorized

func Unauthorized(detail string) error

Unauthorized generates a 401 error.

Types

type Error

type Error struct {
	ID     string `json:"id"`
	Code   int32  `json:"code"`
	Detail string `json:"detail"`
	Status string `json:"status"`
}

Error implements the error interface.

func Parse

func Parse(err string) *Error

Parse tries to parse a JSON string into an error. If that// fails, it will set the given string as the error detail.

func (*Error) Error

func (e *Error) Error() string

Jump to

Keyboard shortcuts

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