flerr

package
v0.0.0-...-d78993e Latest Latest
Warning

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

Go to latest
Published: May 17, 2020 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func PrintAWSError

func PrintAWSError(origErr awserr.Error)

PrintAWSError prints AWS error messages. USAGE

if err != nil {
    if awsErr, ok := err.(awserr.Error); ok {
	       flerr.PrintAWSError(awsErr)
		   return nil, flerr.New(flerr.FogLightAWSServiceError, "failed to describe cloudformation stacks", err)
	    }
}

func SprintError

func SprintError(code FogLightErrorCode, message, extra string, origErr error) string

SprintError returns a string of the formatted error code.

Both extra and origErr are optional. If they are included their lines will be added, but if they are not included their lines will be ignored.

Types

type BatchedErrors

type BatchedErrors interface {
	// Satisfy the base Error interface.
	Error

	// Returns the original error if one was set.  Nil is returned if not set.
	OrigErrs() []error
}

BatchedErrors is a batch of errors which also wraps lower level errors with code, message, and original errors. Calling Error() will include all errors that occurred in the batch.

Replaces BatchError

func NewBatchError

func NewBatchError(code FogLightErrorCode, message string, errs []error) BatchedErrors

NewBatchError returns a BatchedErrors with a collection of errors as an array of errors.

type Error

type Error interface {
	// Satisfy the generic error interface.
	error

	// Returns the short phrase depicting the classification of the error.
	Code() FogLightErrorCode

	// Returns the error details message.
	Message() string

	// Returns the original error if one was set.  Nil is returned if not set.
	OrigErr() error
}

An Error wraps lower level errors with code, message and an original error. The underlying concrete error type may also satisfy other interfaces which can be to used to obtain more specific information about the error.

Calling Error() or String() will always include the full information about an error based on its underlying type.

func New

func New(code FogLightErrorCode, message string, origErr error) Error

New returns an Error object described by the code, message, and origErr.

If origErr satisfies the Error interface it will not be wrapped within a new Error object and will instead be returned.

type FogLightErrorCode

type FogLightErrorCode string

FogLightErrorCode represents a FogLight error code

const (
	// FogLightAPIError you had an issue in the FogLight API
	FogLightAPIError FogLightErrorCode = "FogLightAPIError"
	// FogLightAWSServiceError you had an issue making an AWS API call
	FogLightAWSServiceError FogLightErrorCode = "FogLightAWSServiceError"
	// FogLightBackendError you had an issue in the FogLight backend
	FogLightBackendError FogLightErrorCode = "FogLightBackendError"
	// FogLightClientError you had an issue in the FogLight Client Library
	FogLightClientError FogLightErrorCode = "FogLightClientError"
	// FogLightDynamoDBError you had an issue making a DynamoDB call
	FogLightDynamoDBError FogLightErrorCode = "FogLightDynamoDBError"
	// FogLightJSONUnmarshalError you had an issue unmarshalling JSON
	FogLightJSONUnmarshalError FogLightErrorCode = "FogLightJSONUnmarshalError"
	// FogLightError you should avoid using this error code and use/create a more specific one
	FogLightError FogLightErrorCode = "FogLightError"
	// FogLightStackServiceError you had an issue making an API call to the FogLight stacks service
	FogLightStackServiceError FogLightErrorCode = "FogLightStackServiceError"
)

type UnmarshalError

type UnmarshalError interface {
	Bytes() []byte
	// contains filtered or unexported methods
}

UnmarshalError provides the interface for FogLight failing to unmarshal data.

func NewUnmarshalError

func NewUnmarshalError(err error, msg string, bytes []byte) UnmarshalError

NewUnmarshalError returns an initialized UnmarshalError error wrapper adding the bytes that fail to unmarshal to the error.

Jump to

Keyboard shortcuts

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