sterror

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Dec 4, 2023 License: BSD-2-Clause Imports: 1 Imported by: 0

Documentation

Overview

Package sterror provides the error handling used in stboot. The core part is the constructor function E().

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Error

type Error struct {
	// Op is operation being executed while the error occurde.
	Op Op
	// Scope is the subsytem of stboot causing the error.
	Scope Scope
	// Err is the underlying wrapped error.
	Err error
	// Info provides further context to the error or holds the string
	// value of the triggering error if it is not wrapped.
	Info string
}

Error provides structured and detailed context. However, some fields may be left unset.

An Error value should be created using the E() function.

func E

func E(args ...interface{}) Error

E returns an Error constructed from its arguments. There should be at least one argument, or E returns an unspecifed error. The type of each argument determines its meaning. If more than one argument of a given type is presented, only the last one is recorded.

The types are: sterror.OP - The performed operation. sterror.Scope - The subsystem where the error occurred. error - The underlying error if it should be wrapped. string - Treated as error message of an error that should not be wrapped or as additional information to the provided error.

Further types will be ignored.

func (Error) Error

func (e Error) Error() string

Error implements the error interface.

func (Error) Unwrap added in v0.2.1

func (e Error) Unwrap() []error

Error implements the unwrap interface.

type Op

type Op string

Op describes an operation, usually as the name of the method.

type Scope

type Scope string

Scope defines the scope of error this is, mostly to identify the subsystem where the error occurred. Each subsystem should define exactly one constant as its Scope.

Jump to

Keyboard shortcuts

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