fault

package
v0.0.0-...-ebe7275 Latest Latest
Warning

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

Go to latest
Published: Dec 23, 2024 License: BSD-2-Clause-Patent Imports: 4 Imported by: 36

Documentation

Index

Constants

View Source
const (
	// ResolutionEmpty is equivalent to an empty string.
	ResolutionEmpty = ""
	// ResolutionUnknown indicates that there is no known
	// resolution for the fault.
	ResolutionUnknown = "no known resolution"
	// ResolutionNone indicates that the fault cannot be
	// resolved.
	ResolutionNone = "none"
)
View Source
const (
	UnknownDomainStr      = "unknown"
	UnknownDescriptionStr = "unknown fault"
)

Variables

View Source
var (
	// UnknownFault represents an unknown fault.
	UnknownFault = &Fault{
		Code:       code.Unknown,
		Resolution: ResolutionUnknown,
	}
)

Functions

func HasResolution

func HasResolution(raw error) bool

HasResolution indicates whether or not the error has a resolution defined.

func IsFault

func IsFault(raw error) bool

IsFault indicates whether or not the error is a Fault

func IsFaultCode

func IsFaultCode(raw error, faultCode code.Code) bool

IsFaultCode indicates whether or not the error is a Fault with the given code.

func ShowResolutionFor

func ShowResolutionFor(raw error) string

ShowResolutionFor attempts to return the resolution string for the given error. If the error is not a fault or does not have a resolution set, then the string value of ResolutionUnknown is returned.

Types

type Fault

type Fault struct {
	// Domain indicates the group or family for the fault
	// (e.g. storage, network, etc.) It is used as a prefix
	// when displaying the fault.
	Domain string
	// Code is the unique numeric identifier for known faults.
	Code code.Code
	// Description is the main description of the fault. It usually
	// includes the reason for the fault, and therefore it is not
	// necessary to display both Description and Reason.
	Description string
	// Reason is a short (single sentence) description of the
	// fault, to be displayed where brevity is preferred.
	Reason string
	// Resolution is used to suggest possible solutions for
	// the fault, if appropriate.
	Resolution string
}

Fault represents a well-known error specific to a domain, along with an optional potential resolution for the error.

It implements the error interface and can be used interchangeably with regular "dumb" errors.

func (*Fault) Equals

func (f *Fault) Equals(raw error) bool

Equals attempts to compare the given error to this one. If they both resolve to the same fault code, then they are considered equivalent.

func (*Fault) Error

func (f *Fault) Error() string

Directories

Path Synopsis
Package code is a central repository for all control plane fault codes.
Package code is a central repository for all control plane fault codes.

Jump to

Keyboard shortcuts

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