errors

package
v5.2.1 Latest Latest
Warning

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

Go to latest
Published: Mar 10, 2020 License: BSD-3-Clause Imports: 2 Imported by: 16

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Cause

func Cause(err error) error

Cause returns the underlying cause of the error, if possible. An error value has a cause if it implements the following interface:

type causer interface {
       Cause() error
}

If the error does not implement Cause, the original error will be returned. If the error is nil, nil will be returned without further investigation.

func Errorf

func Errorf(format string, args ...interface{}) error

Errorf formats according to a format specifier and returns the string as a value that satisfies error. Errorf also records the stack trace at the point it was called.

func New

func New(message string) error

New returns an error that formats as the given text.

func NewHttpError

func NewHttpError(httpCode int, message string) error

NewHttpError returns an error based on HTTP status code.

func NewServiceError

func NewServiceError(serviceErrorCode int, httpCode int, message string) error

NewServiceError returns an Service error.

func Wrap

func Wrap(err error, message string) error

Wrap returns an error annotating err with a stack trace at the point Wrap is called, and the supplied message. If err is nil, Wrap returns nil.

Types

type HTTPError

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

HTTPError stores HTTP Status error.

func (HTTPError) HTTPErrorCode

func (httpError HTTPError) HTTPErrorCode() int

GetCode gets HTTP status code.

type SDKError

type SDKError struct {
	HTTPError
	ServiceError
	Message string
}

func ToSdkError

func ToSdkError(err error) (SDKError, bool)

func (SDKError) Error

func (e SDKError) Error() string

func (SDKError) IsHTTPError

func (e SDKError) IsHTTPError() bool

IsHTTPError checks if an error is HTTP status code based error.

func (SDKError) IsServiceError

func (e SDKError) IsServiceError() bool

IsServiceError checks if an error is Service error.

type ServiceError

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

ServiceError stores Service errors.

func (ServiceError) ServiceErrorCode

func (serviceError ServiceError) ServiceErrorCode() int

GetCode gets Service error code.

Jump to

Keyboard shortcuts

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