errors

package
v1.2.2 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2024 License: Apache-2.0 Imports: 4 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

View Source
var StackTracesEnabled = true

Functions

func IsInternalError

func IsInternalError(err error) bool

IsInternalError Checks whether a given error was caused by an InternalError. An error in an internal error, if it has at-least one InternalError in the error chain.

func IsUserError

func IsUserError(err error) bool

IsUserError Checks whether a given error was caused by an UserError. An error in a user error, if it has at-least one UserError in the error chain.

func WrapPanic

func WrapPanic(f func())

Types

type DefaultUserError

type DefaultUserError struct {
	Err error
}

DefaultUserError is the default implementation of UserError interface. It's a generic error that wraps a user error.

func NewDefaultUserError

func NewDefaultUserError(message string, arg ...any) DefaultUserError

func (DefaultUserError) Error

func (e DefaultUserError) Error() string

func (DefaultUserError) IsUserError

func (DefaultUserError) IsUserError()

func (DefaultUserError) Unwrap

func (e DefaultUserError) Unwrap() error

type ErrorNote

type ErrorNote interface {
	Message() string
}

type ErrorNotes

type ErrorNotes interface {
	ErrorNotes() []ErrorNote
}

ErrorNotes is an interface for errors that provide notes

type ExternalError

type ExternalError struct {
	Recovered error
}

ExternalError is an error that occurred externally. It contains the recovered value.

func GetExternalError

func GetExternalError(err error) (ExternalError, bool)

GetExternalError returns the ExternalError in the error chain, if any

func NewExternalError

func NewExternalError(recovered error) ExternalError

func NewExternalNonError

func NewExternalNonError(recovered error) ExternalError

func (ExternalError) Error

func (e ExternalError) Error() string

func (ExternalError) Unwrap

func (e ExternalError) Unwrap() error

type ExternalNonError

type ExternalNonError struct {
	Recovered any
}

ExternalNonError is an non-error-typed panic that occurred externally. It contains the recovered value.

func (ExternalNonError) Error

func (e ExternalNonError) Error() string

type HasPrefix

type HasPrefix interface {
	Prefix() string
}

HasPrefix is an interface for errors that provide a custom prefix

type HasSuggestedFixes

type HasSuggestedFixes[T any] interface {
	SuggestFixes(code string) []SuggestedFix[T]
}

type InternalError

type InternalError interface {
	error
	IsInternalError()
}

InternalError is an implementation error, e.g: an unreachable code path (UnreachableError). A program should never throw an InternalError in an ideal world.

InternalError s must always be thrown and not be caught (recovered), i.e. be propagated up the call stack.

func NewUnreachableError

func NewUnreachableError() InternalError

NewUnreachableError creates an internal error that indicates executing an unimplemented path.

type MemoryError

type MemoryError struct {
	Err error
}

MemoryError indicates a memory limit has reached and should end the Cadence parsing, checking, or interpretation.

func (MemoryError) Error

func (e MemoryError) Error() string

func (MemoryError) IsUserError

func (MemoryError) IsUserError()

func (MemoryError) Unwrap

func (e MemoryError) Unwrap() error

type ParentError

type ParentError interface {
	error
	ChildErrors() []error
}

ParentError is an error that contains one or more child errors.

type SecondaryError

type SecondaryError interface {
	SecondaryError() string
}

SecondaryError is an interface for errors that provide a secondary error message

type SuggestedFix

type SuggestedFix[T any] struct {
	Message   string
	TextEdits []T
}

type UnexpectedError

type UnexpectedError struct {
	Err   error
	Stack []byte
}

UnexpectedError is the default implementation of InternalError interface. It's a generic error that wraps an implementation error, which should have never occurred.

NOTE: This error is not used for errors occur due to bugs in a user-provided program.

func NewUnexpectedError

func NewUnexpectedError(message string, arg ...any) UnexpectedError

func NewUnexpectedErrorFromCause

func NewUnexpectedErrorFromCause(err error) UnexpectedError

func (UnexpectedError) Error

func (e UnexpectedError) Error() string

func (UnexpectedError) IsInternalError

func (UnexpectedError) IsInternalError()

func (UnexpectedError) Unwrap

func (e UnexpectedError) Unwrap() error

type UserError

type UserError interface {
	error
	IsUserError()
}

UserError is an error thrown for an error in the user-code, e.g. exceeding a metering limit.

Jump to

Keyboard shortcuts

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