uerr

package
v0.0.0-...-c113622 Latest Latest
Warning

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

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

Documentation

Overview

Package uerr is the error definition of service and sdk

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrInvalidRequest is the error for invalid request took from user
	ErrInvalidRequest = "client.InvalidRequestError"

	// ErrSendRequest is the error for sending request
	ErrSendRequest = "client.SendRequestError"

	// ErrNetwork is the error for any network error caused by client or server network environment
	// ErrNetwork can be caused by net errors of golang
	// ErrNetwork is retryable
	ErrNetwork = "client.NetworkError"

	// ErrUnexpected is the error for any unexpected error
	ErrUnexpected = "client.UnexpectedError"

	ErrCredentialExpired = "client.CredentialExpiredError"
)
View Source
var (
	// ErrHTTPStatus is error type of http status
	ErrHTTPStatus = "server.HTTPStatusError"
	// ErrRetCode is error type of server return code is larger than 0
	ErrRetCode = "server.RetCodeError"
)

Functions

func IsCodeError

func IsCodeError(err error) bool

IsCodeError will check if the error is the retuen code error

func IsNetworkError

func IsNetworkError(err error) bool

IsNetworkError will check if the error raise from network problem

Types

type ClientError

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

ClientError is the ucloud common errorfor server response

func NewClientError

func NewClientError(name string, err error) ClientError

NewClientError will return a new instance of ClientError

func (ClientError) Code

func (e ClientError) Code() int

Code will return server code

func (ClientError) Error

func (e ClientError) Error() string

func (ClientError) Message

func (e ClientError) Message() string

Message will return message

func (ClientError) Name

func (e ClientError) Name() string

Name will return error name

func (ClientError) OriginError

func (e ClientError) OriginError() error

OriginError will return the origin error that caused by

func (ClientError) Retryable

func (e ClientError) Retryable() bool

Retryable will return if the error is retryable

func (ClientError) StatusCode

func (e ClientError) StatusCode() int

StatusCode will return http status code

type Error

type Error interface {
	error

	// name, should be client.xxx or server.xxx
	Name() string

	// retcode for server api error, retcode > 0 will cause an error
	Code() int

	// http status code, code >= 400 will case an error
	StatusCode() int

	// message for server api error
	Message() string

	// the origin error that sdk error caused from
	OriginError() error

	// if the error is retryable
	Retryable() bool
}

Error is the ucloud sdk error

func NewNonRetryableError

func NewNonRetryableError(err error) Error

NewNonRetryableError will wrap any error as a non-retryable error

func NewRetryableError

func NewRetryableError(err error) Error

NewRetryableError will wrap any error as a retryable error

type ServerError

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

ServerError is the ucloud common error for server response

func NewServerCodeError

func NewServerCodeError(retCode int, message string) ServerError

NewServerCodeError will return a new instance of NewServerStatusError

func NewServerStatusError

func NewServerStatusError(statusCode int, message string) ServerError

NewServerStatusError will return a new instance of NewServerStatusError

func (ServerError) Code

func (e ServerError) Code() int

Code will return server code

func (ServerError) Error

func (e ServerError) Error() string

func (ServerError) Message

func (e ServerError) Message() string

Message will return message

func (ServerError) Name

func (e ServerError) Name() string

Name will return error name

func (ServerError) OriginError

func (e ServerError) OriginError() error

OriginError will return the origin error that caused by

func (ServerError) Retryable

func (e ServerError) Retryable() bool

Retryable will return if the error is retryable

func (ServerError) StatusCode

func (e ServerError) StatusCode() int

StatusCode will return http status code

Jump to

Keyboard shortcuts

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