Documentation ¶
Index ¶
- Variables
- func AnnotateFromStatus(err error, status int, s string, args ...interface{}) error
- func BadGatewayf(s string, args ...interface{}) *badGateway
- func BadRequestf(s string, args ...interface{}) *badRequest
- func Challenge(err error) string
- func Conflictf(s string, args ...interface{}) *conflict
- func Errorf(s string, args ...interface{}) error
- func Forbiddenf(s string, args ...interface{}) *forbidden
- func Found(u string) *redirect
- func FromResponse(resp *http.Response) error
- func Gonef(s string, args ...interface{}) *gone
- func HttpStatus(e error) int
- func IsBadGateway(e error) bool
- func IsBadRequest(e error) bool
- func IsConflict(e error) bool
- func IsForbidden(e error) bool
- func IsGone(e error) bool
- func IsMethodNotAllowed(e error) bool
- func IsNotFound(e error) bool
- func IsNotImplemented(e error) bool
- func IsNotModified(e error) bool
- func IsNotSupported(e error) bool
- func IsNotValid(e error) bool
- func IsRedirect(e error) bool
- func IsTimeout(e error) bool
- func IsUnauthorized(e error) bool
- func Location(err error) string
- func MethodNotAllowedf(s string, args ...interface{}) *methodNotAllowed
- func MovedPermanently(u string) *redirect
- func NewBadGateway(e error, s string, args ...interface{}) *badGateway
- func NewBadRequest(e error, s string, args ...interface{}) *badRequest
- func NewConflict(e error, s string, args ...interface{}) *conflict
- func NewForbidden(e error, s string, args ...interface{}) *forbidden
- func NewFound(e error, u string) *redirect
- func NewFromStatus(status int, s string, args ...interface{}) error
- func NewGone(e error, s string, args ...interface{}) *gone
- func NewMethodNotAllowed(e error, s string, args ...interface{}) *methodNotAllowed
- func NewMovedPermanently(e error, u string) *redirect
- func NewNotFound(e error, s string, args ...interface{}) *notFound
- func NewNotImplemented(e error, s string, args ...interface{}) *notImplemented
- func NewNotModified(e error, u string) *redirect
- func NewNotSupported(e error, s string, args ...interface{}) *notSupported
- func NewNotValid(e error, s string, args ...interface{}) *notValid
- func NewPermanentRedirect(e error, u string) *redirect
- func NewSeeOther(e error, u string) *redirect
- func NewTemporaryRedirect(e error, u string) *redirect
- func NewTimeout(e error, s string, args ...interface{}) *timeout
- func NewUnauthorized(e error, s string, args ...interface{}) *unauthorized
- func NotFoundf(s string, args ...interface{}) *notFound
- func NotImplementedf(s string, args ...interface{}) *notImplemented
- func NotModified(u string) *redirect
- func NotSupportedf(s string, args ...interface{}) *notSupported
- func NotValidf(s string, args ...interface{}) *notValid
- func PermanentRedirect(u string) *redirect
- func RenderErrors(r *http.Request, errs ...error) (int, []byte)
- func SeeOther(u string) *redirect
- func TemporaryRedirect(u string) *redirect
- func Timeoutf(s string, args ...interface{}) *timeout
- func Unauthorizedf(s string, args ...interface{}) *unauthorized
- func WrapWithStatus(status int, err error, s string, args ...interface{}) error
- type Err
- type Error
- type ErrorHandlerFn
- type Frame
- type Http
- type StackTrace
- type StackTracer
Constants ¶
This section is empty.
Variables ¶
Export a number of functions or variables from package errors.
var IncludeBacktrace = true
IncludeBacktrace is a static variable that decides if when creating an error we store the backtrace with it.
var NotFound = ErrorHandlerFn(func(w http.ResponseWriter, r *http.Request) error { return NotFoundf("%s not found", r.URL.Path) })
NotFound is a generic method to return an 404 error HTTP handler that
Functions ¶
func AnnotateFromStatus ¶
func BadGatewayf ¶
func BadGatewayf(s string, args ...interface{}) *badGateway
func BadRequestf ¶
func BadRequestf(s string, args ...interface{}) *badRequest
func Challenge ¶
Challenge returns the challenge of the err parameter if it's an unauthorized type error
func Forbiddenf ¶
func Forbiddenf(s string, args ...interface{}) *forbidden
func FromResponse ¶
func HttpStatus ¶
func IsBadGateway ¶
func IsBadRequest ¶
func IsConflict ¶
func IsForbidden ¶
func IsMethodNotAllowed ¶
func IsNotFound ¶
func IsNotImplemented ¶
func IsNotModified ¶
func IsNotSupported ¶
func IsNotValid ¶
func IsRedirect ¶
func IsUnauthorized ¶
func MethodNotAllowedf ¶
func MethodNotAllowedf(s string, args ...interface{}) *methodNotAllowed
func MovedPermanently ¶
func MovedPermanently(u string) *redirect
func NewBadGateway ¶
func NewBadRequest ¶
func NewConflict ¶
func NewForbidden ¶
func NewFromStatus ¶
func NewMethodNotAllowed ¶
func NewMovedPermanently ¶
func NewNotFound ¶
func NewNotImplemented ¶
func NewNotModified ¶
func NewNotSupported ¶
func NewNotValid ¶
func NewPermanentRedirect ¶
func NewSeeOther ¶
func NewTemporaryRedirect ¶
func NewTimeout ¶
func NewUnauthorized ¶
func NotImplementedf ¶
func NotImplementedf(s string, args ...interface{}) *notImplemented
func NotModified ¶
func NotModified(u string) *redirect
func NotSupportedf ¶
func NotSupportedf(s string, args ...interface{}) *notSupported
func PermanentRedirect ¶
func PermanentRedirect(u string) *redirect
func RenderErrors ¶
RenderErrors outputs the json encoded errors, with the JsonLD ctxt for current
func TemporaryRedirect ¶
func TemporaryRedirect(u string) *redirect
func Unauthorizedf ¶
func Unauthorizedf(s string, args ...interface{}) *unauthorized
Types ¶
type Err ¶
type Err struct {
// contains filtered or unexported fields
}
Err is our custom error type that can store backtrace, file and line number
func (Err) StackTrace ¶
func (e Err) StackTrace() StackTrace
StackTrace returns the stack trace as returned by the debug.Stack function
func (*Err) UnmarshalJSON ¶
type ErrorHandlerFn ¶
type ErrorHandlerFn func(http.ResponseWriter, *http.Request) error
ErrorHandlerFn
func HandleError ¶
func HandleError(e error) ErrorHandlerFn
HandleError is a generic method to return an HTTP handler that passes an error up the chain
func (ErrorHandlerFn) ServeHTTP ¶
func (h ErrorHandlerFn) ServeHTTP(w http.ResponseWriter, r *http.Request)
ServeHTTP implements the http.Handler interface for the ItemHandlerFn type
type Frame ¶
type Frame uintptr
Frame represents a program counter inside a stack frame. For historical reasons if Frame is interpreted as a uintptr its value represents the program counter + 1.
func (Frame) Format ¶
Format formats the frame according to the fmt.Formatter interface.
%s source file %d source line %n function name %v equivalent to %s:%d
Format accepts flags that alter the printing of some verbs, as follows:
%+s function name and path of source file relative to the compile time GOPATH separated by \n\t (<funcname>\n\t<path>) %+v equivalent to %+s:%d
func (Frame) MarshalJSON ¶
func (Frame) MarshalText ¶
MarshalText formats a stacktrace Frame as a text string. The output is the same as that of fmt.Sprintf("%+v", f), but without newlines or tabs.
type Http ¶
type Http struct { Code int `jsonld:"status,omitempty"` Message string `jsonld:"message"` Trace StackTrace `jsonld:"trace,omitempty"` }
func HttpErrors ¶
type StackTrace ¶
type StackTrace []Frame
StackTrace is stack of Frames from innermost (newest) to outermost (oldest).
func (StackTrace) Format ¶
func (st StackTrace) Format(s fmt.State, verb rune)
Format formats the stack of Frames according to the fmt.Formatter interface.
%s lists source files for each Frame in the stack %v lists the source file and line number for each Frame in the stack
Format accepts flags that alter the printing of some verbs, as follows:
%+v Prints filename, function, and line number for each Frame in the stack.
func (StackTrace) MarshalJSON ¶
func (st StackTrace) MarshalJSON() ([]byte, error)
type StackTracer ¶
type StackTracer interface {
StackTrace() StackTrace
}