gtools

package
v0.0.0-...-40f42d4 Latest Latest
Warning

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

Go to latest
Published: Aug 22, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FlattenError

func FlattenError(err error) ([]error, error)

FlattenError takes an error and returns a slice of errors that represent the stack trace of the error, as well as the last error in the stack trace.

Parameters: - err: The error to flatten.

Returns: - []error: a slice of errors representing the stack trace of the error. - Error: The last error in the stack trace.

func ReadTrace

func ReadTrace(stack []error) string

ReadTrace takes a slice of errors and returns a formatted string representing the stack trace of these errors.

Parameters: - stack: a slice of errors representing the stack trace.

Returns: - string: a formatted string representing the stack trace.

func StackErrors

func StackErrors(currentStack []error, currentErr error, newErr error) ([]error, error)

Types

type AggregableOf

type AggregableOf interface {
	ComparableOf
	Add(other AggregableOf) AggregableOf
}

AggregableOf is an interface for types that can be aggregated by a method call

type Barrier

type Barrier interface {
	// Wait causes the current goroutine to wait until the barrier is ready.
	Wait()
	Count() int
	Threshold() int
}

type ComparableOf

type ComparableOf interface {
	Equal(o interface{}) bool
}

ComparableOf is an interface for types that can be compared by a method call

type ConcurrentStackableError

type ConcurrentStackableError struct {
	// contains filtered or unexported fields
}

func NewConcurrentStackableError

func NewConcurrentStackableError(e error) *ConcurrentStackableError

func (*ConcurrentStackableError) Empty

func (s *ConcurrentStackableError) Empty() bool

func (*ConcurrentStackableError) Error

func (s *ConcurrentStackableError) Error() string

func (*ConcurrentStackableError) From

func (*ConcurrentStackableError) Len

func (s *ConcurrentStackableError) Len() int

func (*ConcurrentStackableError) Return

func (s *ConcurrentStackableError) Return() error

func (*ConcurrentStackableError) Stack

func (s *ConcurrentStackableError) Stack(err ...error)

func (*ConcurrentStackableError) String

func (s *ConcurrentStackableError) String() string

func (*ConcurrentStackableError) Trace

func (s *ConcurrentStackableError) Trace() string

func (*ConcurrentStackableError) Unwrap

func (s *ConcurrentStackableError) Unwrap() error

type ErrorLevel

type ErrorLevel struct {
	Key      string
	Severity ErrorSeverity
}

func NewErrorLevel

func NewErrorLevel(key string, severity ErrorSeverity) ErrorLevel

NewErrorLevel creates a new ErrorLevel instance with the provided key and severity.

func (ErrorLevel) String

func (e ErrorLevel) String() string

type ErrorSeverity

type ErrorSeverity int

type LeveledError

type LeveledError interface {
	Error() string
	Level() ErrorLevel
	Severity(err LeveledError) int
}

func AsLeveled

func AsLeveled(err error) (LeveledError, bool)

AsLeveled checks if the given error is of type LeveledError. If it is, it returns the error as LeveledError and true. If it's not, it returns nil and false.

Parameters: - err: The error to check.

Returns: - LeveledError: The error as LeveledError if it's of type LeveledError. - Bool: True if the error is of type LeveledError, false otherwise.

type OperationalError

type OperationalError interface {
	Error() string
	Operation() string
}

func AsOperational

func AsOperational(err error) (OperationalError, bool)

AsOperational is a function that checks if an error is an OperationalError.

Parameters: - err: The error to check.

Returns: - OperationalError: The error as OperationalError if it's of type OperationalError. - bool: True if the error is of type OperationalError, false otherwise.

type OperationalErrorImpl

type OperationalErrorImpl struct {
	// contains filtered or unexported fields
}

func NewOperationalError

func NewOperationalError(op string, err error) *OperationalErrorImpl

func (*OperationalErrorImpl) Error

func (e *OperationalErrorImpl) Error() string

func (*OperationalErrorImpl) Operation

func (e *OperationalErrorImpl) Operation() string

type PersistentSortableOf

type PersistentSortableOf interface {
	SortableOf
	Unique() []byte
}

PersistentSortableOf is an interface for sortable types that are meant to be persisted, so they must be able to be recognizable even when its memory address is changed

type RWSemaphore

type RWSemaphore interface {
	// StartR starts a read operation
	StartR()
	// EndR ends a read operation
	EndR()
	// StartW starts a write operation
	StartW()
	// EndW ends a write operation
	EndW()
}

type Semaphore

type Semaphore interface {
	// Acq acquires the semaphore, blocking if the semaphore is at capacity.
	// This method blocks until the semaphore has available slots.
	Acq()
	// Rls releases a semaphore, allowing another operation to proceed.
	// It blocks until a slot is available in the semaphore's buffer.
	Rls()
}

type SortableOf

type SortableOf interface {
	Less(o interface{}) bool
	ComparableOf
}

SortableOf is an interface for types that can be sorted by a method call

type StackableError

type StackableError interface {
	Trace() string
	Error() string
}

func AsStackable

func AsStackable(err error) (StackableError, bool)

AsStackable checks if the error is of type StackableError and returns it. If the error isn't of type StackableError, it returns nil and false. Returns the error as StackableError and true if successful, nil and false otherwise.

type StackableErrorImpl

type StackableErrorImpl struct {
	// contains filtered or unexported fields
}

func NewStackableError

func NewStackableError(err error) *StackableErrorImpl

func (*StackableErrorImpl) Error

func (s *StackableErrorImpl) Error() string

func (*StackableErrorImpl) Len

func (s *StackableErrorImpl) Len() int

func (*StackableErrorImpl) Stack

func (s *StackableErrorImpl) Stack(e error) error

func (*StackableErrorImpl) Trace

func (s *StackableErrorImpl) Trace() string

func (*StackableErrorImpl) Unwrap

func (s *StackableErrorImpl) Unwrap() error

type WrappedError

type WrappedError interface {
	Error() string
	Unwrap() error
}

func AsWrapped

func AsWrapped(err error) (WrappedError, bool)

AsWrapped checks if the given error is of type WrappedError. If it is, it returns the error as WrappedError and true. If it's not, it returns nil and false.

Parameters: - err: The error to check.

Returns: - WrappedError: The error as WrappedError if it's of type WrappedError. - Bool: True if the error is of type WrappedError, false otherwise.

Jump to

Keyboard shortcuts

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