apierr

package
v0.19.1 Latest Latest
Warning

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

Go to latest
Published: Jun 19, 2015 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Overview

Package apierr represents API error types.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BaseError

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

A BaseError wraps the code and message which defines an error. It also can be used to wrap an original error object.

Should be used as the root for errors satisfying the awserr.Error. Also for any error which does not fit into a specific error wrapper type.

func New

func New(code, message string, origErr error) *BaseError

New returns an error object for the code, message, and err.

code is a short no whitespace phrase depicting the classification of the error that is being created.

message is the free flow string containing detailed information about the error.

origErr is the error object which will be nested under the new error to be returned.

func (*BaseError) Code

func (b *BaseError) Code() string

Code returns the short phrase depicting the classification of the error.

func (*BaseError) Error

func (b *BaseError) Error() string

Error returns the string representation of the error.

See ErrorWithExtra for formatting.

Satisfies the error interface.

func (*BaseError) ErrorWithExtra

func (b *BaseError) ErrorWithExtra(extra string) string

ErrorWithExtra is a helper method to add an extra string to the stratified error message. The extra message will be added on the next line below the error message like the following:

<error code>: <error message>
    <extra message>

If there is a original error the error will be included on a new line.

<error code>: <error message>
    <extra message>
caused by: <original error>

func (*BaseError) Message

func (b *BaseError) Message() string

Message returns the error details message.

func (*BaseError) OrigErr

func (b *BaseError) OrigErr() error

OrigErr returns the original error if one was set. Nil is returned if no error was set.

func (*BaseError) String

func (b *BaseError) String() string

String returns the string representation of the error. Alias for Error to satisfy the stringer interface.

type RequestError

type RequestError struct {
	*BaseError
	// contains filtered or unexported fields
}

A RequestError wraps a request or service error.

Composed of BaseError for code, message, and original error.

func NewRequestError

func NewRequestError(base *BaseError, statusCode int, requestID string) *RequestError

NewRequestError returns a wrapped error with additional information for request status code, and service requestID.

Should be used to wrap all request which involve service requests. Even if the request failed without a service response, but had an HTTP status code that may be meaningful.

Also wraps original errors via the BaseError.

func (*RequestError) Error

func (r *RequestError) Error() string

Error returns the string representation of the error. Satisfies the error interface.

func (*RequestError) RequestID

func (r *RequestError) RequestID() string

RequestID returns the wrapped requestID

func (*RequestError) StatusCode

func (r *RequestError) StatusCode() int

StatusCode returns the wrapped status code for the error

func (*RequestError) String

func (r *RequestError) String() string

String returns the string representation of the error. Alias for Error to satisfy the stringer interface.

Jump to

Keyboard shortcuts

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