errors

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 17, 2020 License: MIT Imports: 4 Imported by: 3

README

Errors

A simple utility for error handling in go/echo microservices

Documentation

Index

Constants

This section is empty.

Variables

View Source
var New = errors.New

New is a drop in replacement for standar errors package

Functions

func Handler

func Handler(err error, c echo.Context)

Handler serializes an error

Types

type Code

type Code string

Code is to make it easier to return a 400

func (Code) Error

func (e Code) Error() string

type HTTPError

type HTTPError interface {
	GetStatusCode() int
}

HTTPError is an interface for structured errors

type Response

type Response struct {
	StatusCode int    `json:"-"`
	Code       string `json:"code,omitempty"`
	Detail     string `json:"detail,omitempty"`
}

Response is the default structure of an error response

func (Response) Error

func (e Response) Error() string

func (Response) GetStatusCode

func (e Response) GetStatusCode() int

GetStatusCode returns the status code

Jump to

Keyboard shortcuts

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