skip

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Sep 12, 2021 License: BSD-2-Clause Imports: 2 Imported by: 0

Documentation

Overview

Package skip provides a frame skipping version of vice for re-use in APIs.

For complete documentation, see the vice package.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Errorf

func Errorf(v Vice, skip uint, format string, a ...interface{}) error

Errorf returns an error that formats as the format specifier, and implements the behaviour described by the given Vice. The argument skip is the number of frames to skip over. Caller(0) returns the frame for the caller of Errorf.

The returned error contains a Frame set to the caller's location and implements Formatter to show this information when printed with details.

This func is intended to be used for implementing APIs on top of vice.

func New

func New(v Vice, skip uint, text string) error

New returns an error that formats as the given text, and implements the behaviour described by the given Vice. The argument skip is the number of frames to skip over. Caller(0) returns the frame for the caller of New.

The returned error contains a Frame set to the caller's location and implements Formatter to show this information when printed with details.

This func is intended to be used for implementing APIs on top of vice.

func Seal

func Seal(err error, v Vice, skip uint, text string) error

Seal returns an error wrapping err with the supplied text, and a frame from the caller's stack. The returned error implements the behaviour described by the given Vice. The argument skip is the number of frames to skip over. Caller(0) returns the frame for the caller of Seal. If err is nil, Seal returns nil.

The error returned does not implement the Unwrap method.

This func is intended to be used for implementing APIs on top of vice.

func Sealf

func Sealf(err error, v Vice, skip uint, format string, a ...interface{}) error

Sealf returns an error wrapping err with the supplied format specifier, and a frame from the caller's stack. The returned error implements the behaviour described by the given Vice. The argument skip is the number of frames to skip over. Caller(0) returns the frame for the caller of Sealf. If err is nil, Sealfreturns nil.

The error returned does not implement the Unwrap method.

This func is intended to be used for implementing APIs on top of vice.

func Wrap

func Wrap(err error, v Vice, skip uint, text string) error

Wrap returns an error wrapping err with the supplied text, and a frame from the caller's stack. The returned error implements the behaviour described by the given Vice. The argument skip is the number of frames to skip over. Caller(0) returns the frame for the caller of Wrap. If err is nil, Wrap returns nil.

The error returned implements the Unwrap method, for programatically extracting the error chain.

This func is intended to be used for implementing APIs on top of vice.

func Wrapf

func Wrapf(err error, v Vice, skip uint, format string, a ...interface{}) error

Wrapf returns an error wrapping err with the supplied format specifier, and a frame from the caller's stack. The returned error implements the behaviour described by the given Vice. The argument skip is the number of frames to skip over. Caller(0) returns the frame for the caller of Wrapf. If err is nil, Wrapf returns nil.

The error returned implements the Unwrap method, for programatically extracting the error chain.

This func is intended to be used for implementing APIs on top of vice.

Types

type Vice

type Vice uint64

Vice is the type used to enumerate all common behaviours for errors. It is mirrored with the main vice package.

const (
	NoVice  Vice = 0
	Timeout Vice = 1 << iota
	Temporary
	Closed
	AuthRequired
	AuthFailed
	Permission
	Conflict
	InvalidArgument
	NotFound
	Internal
	Canceled
	PreconditionFailed
)

These values are mirrored with the main vice package.

Jump to

Keyboard shortcuts

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