errors

package
v0.0.75 Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2024 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package errors provides errors for the evaluator engine

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrUnauthorized is returned when a request is unauthorized
	ErrUnauthorized = errors.New("unauthorized")
	// ErrForbidden is returned when a request is forbidden
	ErrForbidden = errors.New("forbidden")
	// ErrNotFound is returned when a resource is not found
	ErrNotFound = errors.New("not found")
	// ErrValidateOrSpammed is returned when a request is a validation or spammed error
	ErrValidateOrSpammed = errors.New("validation or spammed error")
	// ErrClientError is returned when a request is a client error
	ErrClientError = errors.New("client error")
	// ErrServerError is returned when a request is a server error
	ErrServerError = errors.New("server error")
	// ErrOther is returned when a request is another error
	ErrOther = errors.New("other error")
)
View Source
var ErrActionFailed = errors.New("action failed")

ErrActionFailed is an error code that indicates that the action was attempted but failed.

View Source
var ErrActionNotAvailable = errors.New("action not available")

ErrActionNotAvailable is an error code that indicates that the action was not available for this rule_type

View Source
var ErrActionPending = errors.New("action pending")

ErrActionPending is an error code that indicates that the action was performed but is pending, i.e., opened a PR.

View Source
var ErrActionSkipped = errors.New("action skipped")

ErrActionSkipped is an error code that indicates that the action was not performed at all because the evaluation passed and the action was not needed

View Source
var ErrActionTurnedOff = errors.New("action turned off")

ErrActionTurnedOff is an error code that indicates that the action is turned off for this rule_type

View Source
var ErrEvaluationFailed = errors.New("evaluation failure")

ErrEvaluationFailed is an error that occurs during evaluation of a rule.

View Source
var ErrEvaluationSkipSilently = errors.New("evaluation skipped silently")

ErrEvaluationSkipSilently specifies that the rule was evaluated but skipped silently.

View Source
var ErrEvaluationSkipped = errors.New("evaluation skipped")

ErrEvaluationSkipped specifies that the rule was evaluated but skipped.

View Source
var ErrInternal = errors.New("internal minder error")

ErrInternal is an error that occurs when there is an internal error in the minder engine.

Functions

func AlertErrorAsString

func AlertErrorAsString(err error) string

AlertErrorAsString returns the alert error as a string

func AlertStatusAsError

func AlertStatusAsError(prevStatus *db.ListRuleEvaluationsByProfileIdRow) error

AlertStatusAsError returns the error for a given alert status

func ErrorAsAlertStatus

func ErrorAsAlertStatus(err error) db.AlertStatusTypes

ErrorAsAlertStatus returns the alert status for a given error

func ErrorAsEvalDetails

func ErrorAsEvalDetails(err error) string

ErrorAsEvalDetails returns the evaluation details for a given error

func ErrorAsEvalStatus

func ErrorAsEvalStatus(err error) db.EvalStatusTypes

ErrorAsEvalStatus returns the evaluation status for a given error

func ErrorAsRemediationStatus

func ErrorAsRemediationStatus(err error) db.RemediationStatusTypes

ErrorAsRemediationStatus returns the remediation status for a given error

func EvalErrorAsString

func EvalErrorAsString(err error) string

EvalErrorAsString returns the evaluation error as a string

func HTTPErrorCodeToErr

func HTTPErrorCodeToErr(httpCode int) error

HTTPErrorCodeToErr converts an HTTP error code to an error

func IsActionFatalError

func IsActionFatalError(err error) bool

IsActionFatalError returns true if the error is a fatal error that should stop be reported to the user

func IsActionInformativeError

func IsActionInformativeError(err error) bool

IsActionInformativeError returns true if the error is an informative error that should not be reported to the user

func LimitedWriter

func LimitedWriter(w io.Writer, n int64) io.Writer

LimitedWriter returns a writer that allows up to `n` bytes being written. If more than `n` total bytes are written, `io.ErrShortBuffer` is returned.

func NewDetailedErrEvaluationFailed

func NewDetailedErrEvaluationFailed(
	tmpl string,
	tmplArgs any,
	sfmt string,
	args ...any,
) error

NewDetailedErrEvaluationFailed creates a new evaluation error with a given error message and a templated detail message.

func NewErrActionFailed

func NewErrActionFailed(sfmt string, args ...any) error

NewErrActionFailed creates a new action error

func NewErrEvaluationFailed

func NewErrEvaluationFailed(sfmt string, args ...any) error

NewErrEvaluationFailed creates a new evaluation error with a formatted message.

func NewErrEvaluationSkipSilently

func NewErrEvaluationSkipSilently(sfmt string, args ...any) error

NewErrEvaluationSkipSilently creates a new evaluation error

func NewErrEvaluationSkipped

func NewErrEvaluationSkipped(sfmt string, args ...any) error

NewErrEvaluationSkipped creates a new evaluation error

func RemediationErrorAsString

func RemediationErrorAsString(err error) string

RemediationErrorAsString returns the remediation error as a string

func RemediationStatusAsError

func RemediationStatusAsError(prevStatus *db.ListRuleEvaluationsByProfileIdRow) error

RemediationStatusAsError returns the remediation status for a given error

Types

type ActionsError

type ActionsError struct {
	RemediateErr  error
	RemediateMeta json.RawMessage
	AlertErr      error
	AlertMeta     json.RawMessage
}

ActionsError is the error wrapper for actions

type EvaluationError

type EvaluationError struct {
	Base         error
	Msg          string
	Template     string
	TemplateArgs any
}

EvaluationError is a custom error type for evaluation errors.

func (*EvaluationError) Details

func (e *EvaluationError) Details() string

Details returns a pretty-printed message detailing the reason of the failure.

func (*EvaluationError) Error

func (e *EvaluationError) Error() string

Error implements the error interface for EvaluationError.

func (*EvaluationError) Unwrap

func (e *EvaluationError) Unwrap() error

Unwrap returns the base error, allowing errors.Is to work with wrapped errors.

Jump to

Keyboard shortcuts

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