errors

package module
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 9, 2021 License: Unlicense Imports: 1 Imported by: 5

README

Errors Go Reference

A simple package for creating and wrapping errors in golang

Usage

Creating an error
const ErrEOF = errors.Error("Unexpected end of file")
Wrapping an error
var err error
var config *os.File
if config, err = os.Open("./config.toml");err != nil{
    return errors.Wrap("error getting config file",err)
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Cause

func Cause(err, cause error) error

Cause wraps an error in a another error. This returns nil if `cause` is nil. If `err` is nil `cause` is returned.

func CauseStr added in v1.2.0

func CauseStr(err error, cause string) error

CauseStr like `Cause` but cause is a string instead of an error

func Wrap

func Wrap(str string, err error) error

Wrap wrap the given error. This does nothing if the error is nil.

Types

type Error

type Error string

Error an error that can be used as a constant

func (Error) Error

func (e Error) Error() string

Jump to

Keyboard shortcuts

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