errors

package
v0.0.0 Latest Latest
Warning

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

Go to latest
Published: Jul 11, 2020 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package errors implements functions to manipulate errors.

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(message string) error

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

Example
package main

import (
	"fmt"

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

func main() {
	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

func Wrap(err error) error

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

Example
package main

import (
	"fmt"

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

func main() {
	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

Types

type AppError

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

func (*AppError) Error

func (e *AppError) Error() string

Error returns the string representation of the error message.

func (*AppError) StackTrace

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

func (e *AppError) Unwrap() error

Jump to

Keyboard shortcuts

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