errors

package
v0.0.0-...-6dcaeb9 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2024 License: AGPL-3.0 Imports: 18 Imported by: 119

Documentation

Index

Constants

View Source
const (
	// TODO(juju3): move to params
	ErrBadId              = errors.ConstError("id not found")
	ErrBadCreds           = errors.ConstError("invalid entity name or password")
	ErrNoCreds            = errors.ConstError("no credentials provided")
	ErrLoginExpired       = errors.ConstError("login expired")
	ErrPerm               = errors.ConstError("permission denied")
	ErrNotLoggedIn        = errors.ConstError("not logged in")
	ErrUnknownWatcher     = errors.ConstError("unknown watcher id")
	ErrStoppedWatcher     = errors.ConstError("watcher has been stopped")
	ErrBadRequest         = errors.ConstError("invalid request")
	ErrTryAgain           = errors.ConstError("try again")
	ErrActionNotAvailable = errors.ConstError("action no longer available")
)
View Source
const (
	// DeadlineExceededError is for when a raft operation is enqueued, but the
	// deadline is exceeded.
	DeadlineExceededError = errors.ConstError("deadline exceeded")

	// IncompatibleBaseError indicates the base selected is not supported by the
	// charm.
	IncompatibleBaseError = errors.ConstError("incompatible base for charm")

	NoAddressSetError = errors.ConstError("no address set")

	// UnknownModelError is for when an operation failed to find a model by
	// a given model uuid.
	UnknownModelError = errors.ConstError("unknown model")
)

Variables

This section is empty.

Functions

func DestroyErr

func DestroyErr(desc string, ids []string, errs []error) error

func NewErrIncompatibleBase

func NewErrIncompatibleBase(baseList []base.Base, b base.Base, charmName string) error

func NewNoAddressSetError

func NewNoAddressSetError(unitTag names.UnitTag, addressName string) error

func NewNotLeaderError

func NewNotLeaderError(serverAddress, serverID string) error

NewNotLeaderError creates a new NotLeaderError with the server address and/or server ID of the current raft state leader.

func NotSupportedError

func NotSupportedError(tag names.Tag, operation string) error

func OperationBlockedError

func OperationBlockedError(msg string) error

OperationBlockedError returns an error which signifies that an operation has been blocked; the message should describe what has been blocked.

func RestoreError

func RestoreError(err error) error

RestoreError makes a best effort at converting the given error back into an error originally converted by ServerError(). TODO(juju3): move to params.TranslateWellKnownError Prefer to use the params.TranslateWellKnownError instead.

func SendError

func SendError(w http.ResponseWriter, errToSend error) error

sendError sends a JSON-encoded error response for errors encountered during processing.

func SendStatusAndJSON

func SendStatusAndJSON(w http.ResponseWriter, statusCode int, response interface{}) error

SendStatusAndJSON sends an HTTP status code and a JSON-encoded response to a client.

func ServerError

func ServerError(err error) *params.Error

ServerError returns an error suitable for returning to an API client, with an error code suitable for various kinds of errors generated in packages outside the API.

func ServerErrorAndStatus

func ServerErrorAndStatus(err error) (*params.Error, int)

ServerErrorAndStatus is like ServerError but also returns an HTTP status code appropriate for using in a response holding the given error.

func ServerErrors

func ServerErrors(errs []error) []*params.Error

ServerErrors converts a slice of error into a slice of apiserver errors.

Types

type AccessRequiredError

type AccessRequiredError struct {
	RequiredAccess map[names.Tag]permission.Access
}

AccessRequiredError is the error returned when an api request needs a login token with specified permissions.

func (*AccessRequiredError) AsMap

func (e *AccessRequiredError) AsMap() map[string]interface{}

AsMap returns the data for the info part of an error param struct.

func (*AccessRequiredError) Error

func (e *AccessRequiredError) Error() string

Error implements the error interface.

type DischargeRequiredError

type DischargeRequiredError struct {
	Cause          error
	LegacyMacaroon *macaroon.Macaroon
	Macaroon       *bakery.Macaroon
}

DischargeRequiredError is the error returned when a macaroon requires discharging to complete authentication.

func (*DischargeRequiredError) Error

func (e *DischargeRequiredError) Error() string

Error implements the error interface.

func (*DischargeRequiredError) SendError

func (*DischargeRequiredError) Unwrap

func (e *DischargeRequiredError) Unwrap() error

Unwrap implements errors Unwrap signature.

type HTTPWritableError

type HTTPWritableError interface {
	// Error must at least implement basic error mechanics
	Error() string

	// SendError is responsible for taking a http ResponseWriter and writing an
	// appropriate response to communicate the error back to the client. It's
	// expected that any errors occurred in writing the response are returned to
	// the caller to deal with. After SendError has run successfully is expected
	// that no more writes be performed to the ResponseWriter.
	SendError(http.ResponseWriter) error
}

HTTPWritableError is an error that understands how to write itself onto a http response.

type NotLeaderError

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

NotLeaderError creates a typed error for when a raft operation is applied, but the raft state shows that it's not the leader. The error will help redirect the consumer of the error to workout where they can try and find the leader.

func (*NotLeaderError) AsMap

func (e *NotLeaderError) AsMap() map[string]interface{}

AsMap returns a map of the error. Useful when crossing the facade boundary and wanting information in the client.

func (*NotLeaderError) Error

func (e *NotLeaderError) Error() string

func (*NotLeaderError) ServerAddress

func (e *NotLeaderError) ServerAddress() string

ServerAddress returns the address of the potential current leader. It's not guaranteed to be the leader, as things may of changed when attempting the same request on the new leader.

func (*NotLeaderError) ServerID

func (e *NotLeaderError) ServerID() string

ServerID returns the server ID from the raft state. This should align with the controller machine ID of Juju.

type RedirectError

type RedirectError struct {
	// Servers holds the sets of addresses of the redirected servers.
	// TODO (manadart 2019-11-08): Change this to be either MachineHostPorts
	// or the HostPorts indirection. We don't care about space info here.
	// We can then delete the API params helpers for conversion for this type
	// as it will no longer be used.
	Servers []network.ProviderHostPorts `json:"servers"`

	// CACert holds the certificate of the remote server.
	CACert string `json:"ca-cert"`

	// ControllerTag uniquely identifies the controller being redirected to.
	ControllerTag names.ControllerTag `json:"controller-tag,omitempty"`

	// An optional alias for the controller where the model got redirected to.
	ControllerAlias string `json:"controller-alias,omitempty"`
}

RedirectError is the error returned when a model (previously accessible by the user) has been migrated to a different controller.

func (*RedirectError) Error

func (e *RedirectError) Error() string

Error implements the error interface.

type UpgradeSeriesValidationError

type UpgradeSeriesValidationError struct {
	Cause  error
	Status string
}

UpgradeSeriesValidationError is the error returns when an upgrade-machine can not be run because of a validation error.

func (*UpgradeSeriesValidationError) Error

Error implements the error interface.

Jump to

Keyboard shortcuts

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