errors

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 30, 2017 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Copyright 2017 Applatix, Inc.

Index

Constants

This section is empty.

Variables

View Source
var (
	CodeUnauthorized = "ERR_UNAUTHORIZED"
	CodeBadRequest   = "ERR_BAD_REQUEST"
	CodeForbidden    = "ERR_FORBIDDEN"
	CodeNotFound     = "ERR_NOT_FOUND"
	CodeInternal     = "ERR_INTERNAL"
)

Externally visible error codes

Functions

func Cause

func Cause(err error) error

Cause returns the underlying cause of the error, if possible.

func Errorf

func Errorf(code string, format string, args ...interface{}) error

Errorf formats according to a format specifier and returns the string as a value that satisfies error. Errorf also records the stack trace at the point it was called.

func InternalError

func InternalError(err error) error

InternalError annotates the error with the internal error code and a stack trace

func InternalErrorWithMessage

func InternalErrorWithMessage(err error, message string) error

InternalErrorWithMessage annotates the error with the internal error code and a stack trace and message

func InternalErrorf

func InternalErrorf(err error, format string, args ...interface{}) error

InternalErrorf annotates the error with the internal error code and a stack trace and a formatted message

func New

func New(code string, message string) error

New returns an error with the supplied message. New also records the stack trace at the point it was called.

func WithStack

func WithStack(err error, code string) error

WithStack annotates err with a stack trace at the point WithStack was called. If err is nil, WithStack returns nil.

func Wrap

func Wrap(err error, code string, message string) error

Wrap returns an error annotating err with a stack trace at the point Wrap is called, and a new supplied message. The previous original is preserved and accessible via Cause(). If err is nil, Wrap returns nil.

Types

type APIError

type APIError interface {
	Error() string
	Code() string
	JSON() []byte
	HTTPStatusCode() int
	StackTrace() errors.StackTrace
}

APIError is an error interface that additionally adds support for stack trace, error code, and http status code

Jump to

Keyboard shortcuts

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