errors

package
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2019 License: MIT Imports: 1 Imported by: 0

Documentation

Overview

Package errors implements utilities to handle errors in koazee

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ErrCode

type ErrCode string

ErrCode type used to define the error codes in koazee

const ErrInvalidArgument ErrCode = "err.invalid-argument"

ErrInvalidArgument code for errors produced by an invalid input in the operation

const ErrInvalidIndex ErrCode = "err.invalid-index"

ErrInvalidIndex code for errors related to invalid index when accessing to a position in the stream

const ErrInvalidType ErrCode = "err.invalid-type"

ErrInvalidType code for errors related to invalid type

const ErrItemsNil ErrCode = "err.items-nil"

ErrItemsNil code for errors produced by a nil stream

const ErrUser ErrCode = "err.user-error"

ErrUser code for errors produced by the user's function

func (ErrCode) String

func (c ErrCode) String() string

String print string of error code

type Error

type Error struct {
	// contains filtered or unexported fields
}

Error encapsulates error info

func EmptyStream

func EmptyStream(op string, msg string, args ...interface{}) *Error

EmptyStream creates an item nil error

func InvalidArgument

func InvalidArgument(op string, msg string, args ...interface{}) *Error

InvalidArgument creates a invalid argument error

func InvalidIndex

func InvalidIndex(op string, msg string, args ...interface{}) *Error

InvalidIndex creates a invalid index error

func InvalidType

func InvalidType(op string, msg string, args ...interface{}) *Error

InvalidType creates an invalid type error

func New

func New(operation string, code ErrCode, msgFormat string, args ...interface{}) *Error

New creates a new instance of Error

func UserError added in v0.0.4

func UserError(op string, err error) *Error

UserError creates a user error

func (Error) Code

func (e Error) Code() string

Code returns the code for the error

func (Error) Error

func (e Error) Error() string

Error converts the error into a readable message

func (Error) Operation

func (e Error) Operation() string

Operation returns the operation associated to the error

func (*Error) UserError added in v0.0.4

func (e *Error) UserError() error

UserError returns the error from the user's function, if any.

func (Error) With

func (e Error) With(key string, value interface{}) Error

With permits add extra info to show displayed when printing the error

Jump to

Keyboard shortcuts

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