internal

package
v0.0.0-...-13e599b Latest Latest
Warning

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

Go to latest
Published: Aug 8, 2022 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Errorf

func Errorf(code ECode, formant string, a ...interface{}) error

Errorf formats a new error.

func StatusCodeFromECode

func StatusCodeFromECode(code ECode) int

func WrapError

func WrapError(origin error, code ECode, format string, a ...interface{}) error

WrapError wraps the origin error in the Error type with the formated new error.

func WrapErrorNil

func WrapErrorNil(origin error, code ECode, format string, a ...interface{}) error

Types

type ECode

type ECode uint8

ECode represents an error code in the system.

const (
	ECONFLICT ECode = iota + 1
	EINTERNAL
	EINVALID
	ENOTFOUND
)

Error codes which map good to http errors.

func ECodeFromStatusCode

func ECodeFromStatusCode(code int) ECode

ECodeFromStatusCode is a helper function to map a http status code to a error

if code not found: returns EINTERNAL

func ErrorCode

func ErrorCode(err error) ECode

ErrorCode is a helper function to get the code for any error.

if error nil: returns 0

if error not of type internal.Error: EINTERNAL

if error of type internal.Error: code of error

type Error

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

Error represents an internal error which implements the error interface.

func (*Error) Code

func (e *Error) Code() ECode

Code returns the error code under the error.

func (*Error) Error

func (e *Error) Error() string

Error returns the message, when wrapped we return the wrapped error message with the current error message.

func (*Error) Unwrap

func (e *Error) Unwrap() error

Unwrap returns the original error.

type Friendship

type Friendship struct {
	P1   *Person `json:"p1"`
	With []int64 `json:"with"`
}

Friendship represents a friendship from the perspective of P1.

func (Friendship) Validate

func (f Friendship) Validate() error

type Person

type Person struct {
	ID        int64     `json:"id"`
	Name      string    `json:"name"`
	CreatedAt time.Time `json:"createdAt"`
}

func (*Person) Validate

func (p *Person) Validate() error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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