errors

package
v0.0.0-...-fd00b2c Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var As = errors.As

As is equavalent to errors.As

View Source
var Errorf = fmt.Errorf

Errorf is equavalent to fmt.Errorf

View Source
var New = errors.New

New is equavalent to errors.New

View Source
var Separator = ":\n\t"

Separator is the string used to separate nested errors. By default, to make errors easier on the eye, nested errors are indented on a new line. A server may instead choose to keep each error on a single line by modifying the separator string, perhaps to ":: ".

Functions

func E

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

E builds an error value from its arguments. There must be at least one argument or E panics. 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:

radio.SongID:
	The song identifier of the song involved
radio.TrackID:
	The track identifier of the song involved
radio.Song, radio.QueueEntry:
	The song involved, fills in both SongID and TrackID above
errors.Delay:
	The delay until this error is resolved
errors.Info:
	Extra info useful to this class of error, think argument
	name when using InvalidArgument
errors.Op:
	The operation being performed
string:
	Treated as an error message and assigned to the
	Err field after a call to errors.New
errors.Kind:
	The class of error
error:
	The underlying error that triggered this one

If the error is printed, only those items that have been set to non-zero values will appear in the result.

If Kind is not specified or Other, we set it to the Kind of the underlying error.

func Is

func Is(kind Kind, err error) bool

Is reports whether err is an *Error of the given kind

func IsE

func IsE(err error, targets ...error) bool

IsE is equavalent to errors.Is, except it allows multiple targets

Types

type Delay

type Delay time.Duration

Delay is the amount of time still left on a cooldown

func SelectDelay

func SelectDelay(err error) (Delay, bool)

SelectDelay returns the first non-zero Delay found in the error given, if none is found ok will be false

type Error

type Error struct {
	Kind    Kind
	Op      Op
	SongID  radio.SongID
	TrackID radio.TrackID
	Delay   Delay
	Info    Info
	Err     error
}

Error is the type that implements the error interface. It contains a number of fields, each of different type. An Error value may leave some values unset.

func Select

func Select(kind Kind, err error) (*Error, bool)

Select returns an *Error with the given Kind from the error given

func (*Error) Error

func (e *Error) Error() string

func (*Error) Is

func (e *Error) Is(err error) bool

Is reports whether err is the same kind as the receiver, but does not unwrap wrapped errors to check them. This is left to the Is function.

func (*Error) Unwrap

func (e *Error) Unwrap() error

Unwrap returns the wrapped error value

type Info

type Info string

Info is some extra information that can be included with an Error

type Kind

type Kind uint8

Kind defines the kind of error this is

const (
	Other                  Kind = iota // Unclassified error
	InvalidArgument                    // Invalid argument given to function
	SongUnknown                        // Song does not exist
	SongWithoutTrack                   // Song did not have required track fields
	SongUnusable                       // Song is not playable by streamer
	SongCooldown                       // Song is on request cooldown
	UserCooldown                       // User is on request cooldown
	UserUnknown                        // User does not exist
	StreamerNotRunning                 // Streamer isn't running
	StreamerRunning                    // Streamer is already running
	StreamerAlreadyStopped             // Streamer is already stopping
	StreamerNoRequests                 // Streamer requests are disabled
	QueueEmpty                         // Queue is empty
	QueueExhausted                     // Queue has no more songs
	QueueShort                         // Queue is short songs
	SearchIndexExists                  // Search index already exists
	SearchNoResults                    // Search had no results
	BrokenTopic                        // IRC channel topic broken
	TransactionBegin                   // Database begin transaction failure
	TransactionRollback                // Database rollback transaction failure
	TransactionCommit                  // Database commit transaction failure
	ProviderUnknown                    // Unknown service provider name used
	NotImplemented                     // Generic error indicating something is not implemented
	NewsUnknown                        // News post does not exist
	SessionUnknown                     // Session does not exist
	InvalidForm                        // Form submitted was invalid
	InternalServer                     // InternalServer error, these return 501
	AccessDenied                       // Someone tried to access something they're not allowed to
	NoRelays                           // No relays were found in the DB.
	TemplateUnknown                    // Template does not exist
	TemplateParseError                 // Template failed to parse
	Testing                            // For testing purposes
	NoMigrations                       // indicates there were no storage migrations
	DirtyMigration                     // indicates the migration failed to apply and is in a dirty state
	MigrationNotApplied                // indicates not all migrations were applied
	LoginError                         // Login error
)

Kinds of errors

Do not reorder this list or remove items; New items must be added only to the end

func (Kind) String

func (k Kind) String() string

type Op

type Op string

Op is the operation that was being performed

Jump to

Keyboard shortcuts

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