errors

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Oct 10, 2019 License: Apache-2.0 Imports: 3 Imported by: 2 modules, 6 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AssertIsHTTPErrOfCode

func AssertIsHTTPErrOfCode(t *testing.T, err error, code int)

AssertIsHTTPErrOfCode performs 4 assertions: 0. err is actually an error 1. err is an HTTPErr instance 2. err.Code = the given code 3. err.Inner != nil

Types

type HTTPErr

type HTTPErr struct {
	Code  int   // The HTTP error code to use for this error
	Inner error // The actual error of this HTTPErr struct
}

HTTPErr provides a basic struct to pass up which HTTP status code should be used with this error

func MakeBadRequestHTTPErr

func MakeBadRequestHTTPErr(err error) *HTTPErr

MakeBadRequestHTTPErr is a wrapper for MakeHTTPErr that passes in http.StatusBadRequest, since we use that response quite often

func MakeHTTPErr

func MakeHTTPErr(code int, err error) *HTTPErr

MakeHTTPErr constructs an HTTPErr instance: this mainly makes it a bit easier to read and pass into return statements

func MakeInternalHTTPErr

func MakeInternalHTTPErr(err error) *HTTPErr

MakeInternalHTTPErr is a wrapper for MakeHTTPErr that passes in http.StatusInternalServerError, since we use that response quite often

func (*HTTPErr) Error

func (e *HTTPErr) Error() string

HTTPErr.Error is simply a wrapper around the inner error's Error() method with a nil check

type JSONErr

type JSONErr struct {
	Code int    `json:"code"`
	Text string `json:"text"`
}

JSONErr provides a common error struct for JSON

Jump to

Keyboard shortcuts

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