Help us shape the future of Go! Take the 2026 Go Developer Survey

errors

package module
v0.0.0-...-eaa29fc Latest Latest
Warning

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

Go to latest
Published: Apr 11, 2019 License: MIT Imports: 6 Imported by: 0

README

errors

A simple error package for simple go apps.

Usage

errors.New(a...) can take an error, a string, or (string, interface...).
It will log the error with stack trace, and return errorlog type, which implements error interface.
Use errors_test.go to check usages.

Example

wrap error

return errors.New(err)

take a string

return errors.New(msg)

take (string, interface...)

return errors.New("user(%v) does not exist.", id)

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(a ...interface{}) errorlog

New returns errorlog, which implements error interface, and log error with stack trace.

Types

type Frame

type Frame uintptr

Frame represents a program counter inside a stack frame.

func (Frame) Format

func (f Frame) Format(s fmt.State, verb rune)

Format formats the frame according to the fmt.Formatter interface.

%s    source file
%d    source line
%n    function name
%v    equivalent to %s:%d

Format accepts flags that alter the printing of some verbs, as follows:

%+s   path of source file relative to the compile time GOPATH
%+v   equivalent to %+s:%d

type StackTrace

type StackTrace []Frame

StackTrace is stack of Frames from innermost (newest) to outermost (oldest).

func (StackTrace) Format

func (st StackTrace) Format(s fmt.State, verb rune)

Jump to

Keyboard shortcuts

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