errors

package
v0.3.6 Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2021 License: GPL-3.0 Imports: 7 Imported by: 0

Documentation

Overview

Package errors provides error interfaces and utility functions for all packages.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckAPIError

func CheckAPIError(r *http.Response) error

CheckAPIError evaluates if the HTTP response contains an API error. If so, an attempt is made to unmarshal it into an API error. If this fails, then an error containing the original body is returned, or any error from attempting to read the body.

func IsAPIForbidden

func IsAPIForbidden(err error) bool

IsAPIForbidden checks if the given error from the API is a Forbidden error.

func IsAPINotFound

func IsAPINotFound(err error) bool

IsAPINotFound checks if the given error from the API is a NotFound error.

func IsAPIServerError

func IsAPIServerError(err error) bool

IsAPIServerError checks if the given error from the API is a ServerError error.

func IsAPIUnauthorized

func IsAPIUnauthorized(err error) bool

IsAPIUnauthorized checks if the given error from the API is a Unauthorized error.

func IsBrokenPipeError

func IsBrokenPipeError(err error) bool

IsBrokenPipeError returns true if the error is from trying to write to a closed connection.

func IsRoleNotFoundError

func IsRoleNotFoundError(err error) bool

IsRoleNotFoundError returns true if the given error interface is a RoleNotFoundError.

func IsSecretNotFoundError

func IsSecretNotFoundError(err error) bool

IsSecretNotFoundError returns true if the given error is a SecretNotFoundError.

func IsUserNotFoundError

func IsUserNotFoundError(err error) bool

IsUserNotFoundError returns true if the given error interface is a UserNotFoundError.

func New

func New(msg string) error

New wraps the stdlib errors.New for simplicity when using this package.

func NewRoleNotFoundError

func NewRoleNotFoundError(role string) error

NewRoleNotFoundError returns a new RoleNotFoundError for the provided role.

func NewSecretNotFoundError

func NewSecretNotFoundError(secret string) error

NewSecretNotFoundError returns a new SecretNotFoundError for the given resource name.

func NewUserNotFoundError

func NewUserNotFoundError(user string) error

NewUserNotFoundError returns a new UserNotFoundError for the provided username.

Types

type APIError

type APIError struct {
	// A message describing the error
	ErrMsg string `json:"error"`
	// The status for the error.
	ErrStatus ErrorStatus `json:"status"`
}

APIError is for errors from the API server. It's main purpose is to provide a quick interface for returning json encoded error messages

func ToAPIError

func ToAPIError(err error, errStatus ErrorStatus) *APIError

ToAPIError converts a generic error into an API error

func (*APIError) Error

func (r *APIError) Error() string

Error implements the error interface

func (*APIError) JSON

func (r *APIError) JSON() []byte

JSON returns the json encoded error. Error checking is skipped since this is only used internally and for valid strings.

type ErrorStatus

type ErrorStatus string

ErrorStatus represents a type of API error

const (
	Unauthorized ErrorStatus = "Unauthorized"
	Forbidden    ErrorStatus = "Forbidden"
	NotFound     ErrorStatus = "NotFound"
	ServerError  ErrorStatus = "ServerError"
)

Error types

type RequeueError

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

RequeueError is used to float errors back up to the controller signalling that an error has not actually ocurred, but instead the reconcile attempt should be requeued due to a resource not being ready.

func IsRequeueError

func IsRequeueError(err error) (*RequeueError, bool)

IsRequeueError returns true if the provided error interface is a RequeueError. If it is a requeue error, return the underlying object.

func NewRequeueError

func NewRequeueError(msg string, requeueSeconds int) *RequeueError

NewRequeueError returns a new requeue error. The provided string will be logged, and the reconcile will be requeued after the given number of seconds.

func (*RequeueError) Duration

func (r *RequeueError) Duration() time.Duration

Duration returns the wait time for this error

func (*RequeueError) Error

func (r *RequeueError) Error() string

Error implements the error interface

type RoleNotFoundError

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

RoleNotFoundError is an error signaling that the requested role was not found.

func (*RoleNotFoundError) Error

func (r *RoleNotFoundError) Error() string

Error implements the error interface.

type SecretNotFoundError

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

SecretNotFoundError is used to signal from a secrets backend that the requested secret does not exist.

func (*SecretNotFoundError) Error

func (r *SecretNotFoundError) Error() string

Error implements the error interface

type UserNotFoundError

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

UserNotFoundError is an error signaling that the requested user was not found.

func (*UserNotFoundError) Error

func (r *UserNotFoundError) Error() string

Error implements the error interface.

Jump to

Keyboard shortcuts

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