errors

package
v0.1.6 Latest Latest
Warning

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

Go to latest
Published: Aug 16, 2022 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package errors provides an identical API to the popular github.com/pkg/errors package. It also provides several feature enhancements.

Stack Traces

github.com/pkg/errors includes a stacktrace for every wrapped call. This creates a lot of noise in applications since we prefer to always a wrap an error to ensure a logged error always has a stacktrace. This package attempts to remove stack traces when it can detect the traces have a shared caller. Typically you are left with only the root stack trace.

Index

Constants

View Source
const (
	InvalidStatement = iota + 1000
	SchemaNotInUse
	UnknownSource
	UnknownMaterializedView
	UnknownIndex
	UnknownTable
	SourceAlreadyExists
	MaterializedViewAlreadyExists
	IndexAlreadyExists
	SourceHasChildren
	MaterializedViewHasChildren
	InvalidParamCount
	Timeout
	DdlCancelled
	Unavailable
	DdlRetry
)

User errors

View Source
const (
	ValueOutOfRange = iota + 2000
	VarcharTooBig
)

Ingest errors

View Source
const (
	InvalidConfiguration = 3000
	UnknownPerfCommand   = 4000
	InternalError        = 5000
)

Miscellaneous errors

Variables

This section is empty.

Functions

func AddStack

func AddStack(err error) error

func As

func As(err error, target interface{}) bool

As finds the first error in err's chain that matches target, and if so, sets target to that error value and returns true.

The chain consists of err itself followed by the sequence of errors obtained by repeatedly calling Unwrap.

An error matches target if the error's concrete value is assignable to the value pointed to by target, or if the error has a method As(interface{}) bool such that As(target) returns true. In the latter case, the As method is responsible for setting target.

As will panic if target is not a non-nil pointer to either a type that implements error, or to any interface type. As returns false if err is nil.

func Cause

func Cause(err error) error

Cause returns the underlying cause of the error, if possible. An error value has a cause if it implements the following interface:

type causer interface {
       Cause() error
}

If the error does not implement Cause, the original error will be returned. If the error is nil, nil will be returned without further investigation.

func Error

func Error(msg string) error

func ErrorEqual

func ErrorEqual(err1 error, err2 error) bool

func Errorf

func Errorf(format string, args ...interface{}) error

Errorf formats according to a format specifier and returns the string as a value that satisfies error. Errorf also records the stack trace at the point it was called.

func Is

func Is(err, target error) bool

Is reports whether any error in err's chain matches target.

The chain consists of err itself followed by the sequence of errors obtained by repeatedly calling Unwrap.

An error is considered to match a target if it is equal to that target or if it implements a method Is(error) bool such that Is(target) returns true.

func MaybeConvertToPranaErrorf added in v0.1.1

func MaybeConvertToPranaErrorf(err error, errorCode ErrorCode, msgFormat string, args ...interface{}) error

func New

func New(message string) error

New returns an error with the supplied message. New also records the stack trace at the point it was called.

func Trace

func Trace(err error) error

func WithStack

func WithStack(err error) error

WithStack annotates err with a stack trace at the point WithStack was called. If err is nil, WithStack returns nil.

func Wrap

func Wrap(err error, message string) error

Wrap returns an error annotating err with a stack trace at the point Wrap is called, and the supplied message. If err is nil, Wrap returns nil.

Types

type ErrorCode

type ErrorCode int

type PranaError

type PranaError struct {
	Code ErrorCode
	Msg  string
}

PranaError is any kind of error that is exposed to the user via external interfaces like the CLI

func NewIndexAlreadyExistsError

func NewIndexAlreadyExistsError(schemaName string, tableName string, indexName string) PranaError

func NewInternalError

func NewInternalError(errReference string) PranaError

func NewInvalidConfigurationError

func NewInvalidConfigurationError(msg string) PranaError

func NewInvalidStatementError

func NewInvalidStatementError(msg string) PranaError

func NewMaterializedViewHasChildrenError

func NewMaterializedViewHasChildrenError(schemaName string, materializedViewName string, childMVs []string) PranaError

func NewPranaError

func NewPranaError(errorCode ErrorCode, msg string) PranaError

func NewPranaErrorf

func NewPranaErrorf(errorCode ErrorCode, msgFormat string, args ...interface{}) PranaError

func NewSchemaNotInUseError

func NewSchemaNotInUseError() PranaError

func NewSourceHasChildrenError

func NewSourceHasChildrenError(schemaName string, sourceName string, childMVs []string) PranaError

func NewUnknownIndexError

func NewUnknownIndexError(schemaName string, tableName string, indexName string) PranaError

func NewUnknownLoadRunnerfCommandError

func NewUnknownLoadRunnerfCommandError(commandName string) PranaError

func NewUnknownMaterializedViewError

func NewUnknownMaterializedViewError(schemaName string, mvName string) PranaError

func NewUnknownSourceError

func NewUnknownSourceError(schemaName string, sourceName string) PranaError

func NewUnknownTableError added in v0.1.1

func NewUnknownTableError(schemaName string, tableName string) PranaError

func NewValueOutOfRangeError

func NewValueOutOfRangeError(msg string) PranaError

func (PranaError) Error

func (u PranaError) Error() string

Jump to

Keyboard shortcuts

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