errors

package
v1.3.1 Latest Latest
Warning

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

Go to latest
Published: Jun 13, 2019 License: MIT Imports: 1 Imported by: 48

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ErrorCode

func ErrorCode(err error) string

ErrorCode returns the code if the given error is a store error and has a code assigned, otherwise returns an empty string

func FilterCode

func FilterCode(code Code) string

FilterCode turns unknown error codes to empty strings

Types

type Code

type Code string

Code represents an error code

const (
	// ErrCanceled is thrown when a transaction is canceled
	ErrCanceled Code = "Canceled"

	// ErrUnauthorized is thrown when the API user is unauthorized to perform
	// the request
	ErrUnauthorized Code = "Unauthorized"

	// ErrInvalidInput is thrown when the API user input is invalid
	ErrInvalidInput Code = "InvalidInput"

	// ErrWrongCreds is thrown when the API user provides wrong authentication
	// credentials
	ErrWrongCreds Code = "WrongCreds"
)

type Error

type Error struct {
	Code    string
	Message string
}

Error represents a typed store error

func New

func New(code Code, message string) Error

New creates a new store error

func Newf

func Newf(code Code, format string, v ...interface{}) Error

Newf creates a new store error

func Wrap

func Wrap(code Code, err error) Error

Wrap wraps an error into a new store error

func (Error) Error

func (err Error) Error() string

Error implements the error interface

Jump to

Keyboard shortcuts

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