errors

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Mar 23, 2016 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Code

type Code int

Code is custom error code

const (
	ErrCodeUnknown Code
	ErrCodeNotFound
	ErrCodeInsufficientBalance
)

error codes

const (
	ErrCodeDuplicateEmail Code
	ErrCodeDuplicateAddress
	ErrCodeDuplicateAuthToken
)

duplicate error

const (
	ErrCodeMandrill Code
)

external service error

type Error

type Error struct {
	ErrCode             Code
	ErrStringForLogging string
}

Error is custom error

Example
e := New(ErrCodeDuplicateEmail)
e.ErrStringForLogging = "for logging purpose"
fmt.Println(e)

raw, _ := json.Marshal(e)
fmt.Println(string(raw))
Output:

5001
{"code":5001}

func New

func New(c Code) *Error

New creates new *Error with error code

func (*Error) Error

func (e *Error) Error() string

err implements error interface

func (*Error) MarshalJSON

func (e *Error) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler interface

Jump to

Keyboard shortcuts

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