errors

package
v0.0.0-...-f890545 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2024 License: GPL-3.0 Imports: 4 Imported by: 6

Documentation

Overview

The errors package defines common error types which are used across the prompting subsystems, along with constructors for specific errors based on those broader types.

Index

Constants

This section is empty.

Variables

View Source
var (
	// NotFound errors when a prompt or rule is not found
	ErrPromptNotFound = errors.New("cannot find prompt with the given ID for the given user")
	ErrRuleNotFound   = errors.New("cannot find rule with the given ID")
	ErrRuleNotAllowed = errors.New("user not allowed to request the rule with the given ID")

	// Validation errors, which should never be used directly apart from
	// checking errors.Is(), and should otherwise always be wrapped in
	// dedicated error types defined below.
	ErrReplyNotMatchRequestedPath        = errors.New("path pattern in reply constraints does not match originally requested path")
	ErrReplyNotMatchRequestedPermissions = errors.New("permissions in reply constraints do not include all requested permissions")
	ErrRuleConflict                      = errors.New("a rule with conflicting path pattern and permission already exists in the rule database")

	// Internal errors which are not handled specifically
	ErrPromptsClosed      = errors.New("prompts backend has already been closed")
	ErrRulesClosed        = errors.New("rules backend has already been closed")
	ErrTooManyPrompts     = errors.New("cannot add new prompts, too many outstanding")
	ErrRuleIDConflict     = errors.New("internal error: rule with conflicting ID already exists in the rule database")
	ErrRuleDBInconsistent = errors.New("internal error: interfaces requests rule database left inconsistent")

	// Errors which are used internally and should never be returned over the API
	ErrNoMatchingRule          = errors.New("no rule matches the given path")
	ErrInvalidID               = errors.New("invalid ID: format must be parsable as uint64")
	ErrRuleExpirationInThePast = errors.New("cannot have expiration time in the past")
)
View Source
var ErrParseError = errors.New("parse error")

Marker for ParseError, should never be returned as an actual error value.

View Source
var ErrUnsupportedValue = errors.New("unsupported value")

Marker for UnsupportedValueError, should never be returned as an actual error value.

Functions

This section is empty.

Types

type ParseError

type ParseError struct {
	Field   string
	Msg     string
	Invalid string
}

ParseError is a wrapper for errors about a field whose value is malformed.

func NewInvalidDurationError

func NewInvalidDurationError(invalid string, reason string) *ParseError

func NewInvalidExpirationError

func NewInvalidExpirationError(invalid time.Time, reason string) *ParseError

func NewInvalidPathPatternError

func NewInvalidPathPatternError(invalid string, reason string) *ParseError

func (*ParseError) Error

func (e *ParseError) Error() string

func (*ParseError) Unwrap

func (e *ParseError) Unwrap() error

type RequestedPathNotMatchedError

type RequestedPathNotMatchedError struct {
	Requested string
	Replied   string
}

RequestedPathNotMatchedError stores a path pattern from a reply which doesn't match the requested path.

func (*RequestedPathNotMatchedError) Error

func (*RequestedPathNotMatchedError) Unwrap

func (e *RequestedPathNotMatchedError) Unwrap() error

type RequestedPermissionsNotMatchedError

type RequestedPermissionsNotMatchedError struct {
	Requested []string
	Replied   []string
}

RequestedPermissionsNotMatchedError stores the list of permissions from a reply which doesn't include all the requested permissions.

func (*RequestedPermissionsNotMatchedError) Error

func (*RequestedPermissionsNotMatchedError) Unwrap

type RuleConflict

type RuleConflict struct {
	Permission    string
	Variant       string
	ConflictingID string
}

RuleConflict stores the permission and rendered variant which conflicted with that of another rule, along with the ID of that conflicting rule.

type RuleConflictError

type RuleConflictError struct {
	Conflicts []RuleConflict
}

RuleConflictError stores a list of conflicts with existing rules which occurred when attempting to add or patch a rule.

func (*RuleConflictError) Error

func (e *RuleConflictError) Error() string

func (*RuleConflictError) Unwrap

func (e *RuleConflictError) Unwrap() error

type UnsupportedValueError

type UnsupportedValueError struct {
	Field     string
	Msg       string
	Value     []string
	Supported []string
}

UnsupportedValueError is a wrapper for errors about a field having an unsupported value when there is a fixed set of supported values.

func NewInvalidInterfaceError

func NewInvalidInterfaceError(unsupported string, supported []string) *UnsupportedValueError

func NewInvalidLifespanError

func NewInvalidLifespanError(unsupported string, supported []string) *UnsupportedValueError

func NewInvalidOutcomeError

func NewInvalidOutcomeError(unsupported string, supported []string) *UnsupportedValueError

func NewInvalidPermissionsError

func NewInvalidPermissionsError(iface string, unsupported []string, supported []string) *UnsupportedValueError

func NewPermissionsListEmptyError

func NewPermissionsListEmptyError(iface string, supported []string) *UnsupportedValueError

func NewRuleLifespanSingleError

func NewRuleLifespanSingleError(supported []string) *UnsupportedValueError

func (*UnsupportedValueError) Error

func (e *UnsupportedValueError) Error() string

func (*UnsupportedValueError) Is

func (e *UnsupportedValueError) Is(target error) bool

Jump to

Keyboard shortcuts

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