errors

package
v0.0.0-...-267b159 Latest Latest
Warning

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

Go to latest
Published: Dec 17, 2023 License: Apache-2.0 Imports: 2 Imported by: 27

Documentation

Overview

Contains utilities to use to create and consume simple errors.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Errorf

func Errorf(errorCode ErrorCode, msgFmt string, args ...interface{}) error

Creates a new error using an error code and a message.

func IsCausedBy

func IsCausedBy(e error, errCode ErrorCode) bool

Gets whether error is caused by another error with errCode.

func IsCausedByError

func IsCausedByError(e, e2 error) bool

func Wrapf

func Wrapf(code ErrorCode, cause error, msgFmt string, args ...interface{}) error

Wraps a root cause error with another. This is useful to unify an error type in a package.

Types

type ErrorCode

type ErrorCode = string

A generic error code type.

func GetErrorCode

func GetErrorCode(e error) (code ErrorCode, found bool)

Gets the error code of the passed error if it has one.

type ErrorCollection

type ErrorCollection []error

A helper object that collects errors.

func (*ErrorCollection) Append

func (e *ErrorCollection) Append(err error) bool

func (ErrorCollection) Error

func (e ErrorCollection) Error() string

func (ErrorCollection) ErrorOrDefault

func (e ErrorCollection) ErrorOrDefault() error

Jump to

Keyboard shortcuts

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