go-api-boilerplate: github.com/vardius/go-api-boilerplate/pkg/errors Index | Examples | Files

package errors

import "github.com/vardius/go-api-boilerplate/pkg/errors"

Package errors implements functions to manipulate errors.

Index

Examples

Package Files

errors.go

func New Uses

func New(message string) error

New returns new app error that formats as the given text.

Code:

err := errors.New("example")

fmt.Printf("%s\n", err)

Output:

example:
	/home/travis/gopath/src/github.com/vardius/go-api-boilerplate/pkg/errors/example_test.go:10

func Wrap Uses

func Wrap(err error) error

Wrap returns new app error wrapping target error. If passed value is nil will fallback to internal

Code:

subErr := errors.New("example")
err := errors.Wrap(subErr)

fmt.Printf("%s\n", err)

Output:

/home/travis/gopath/src/github.com/vardius/go-api-boilerplate/pkg/errors/example_test.go:21
example:
	/home/travis/gopath/src/github.com/vardius/go-api-boilerplate/pkg/errors/example_test.go:20

type AppError Uses

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

func (*AppError) Error Uses

func (e *AppError) Error() string

Error returns the string representation of the error message.

func (*AppError) StackTrace Uses

func (e *AppError) StackTrace() (string, error)

StackTrace returns the string representation of the error stack trace, includeTrace appends caller pcs frames to each error message if possible.

func (*AppError) Unwrap Uses

func (e *AppError) Unwrap() error

Package errors imports 5 packages (graph) and is imported by 14 packages. Updated 2020-08-04. Refresh now. Tools for package owners.