errortypes

package
v1.0.6 Latest Latest
Warning

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

Go to latest
Published: Sep 20, 2020 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Overview

Package errortypes defines all exceptions happened in dragonfly.

Package errortypes defines all exceptions happened in supernode's runtime.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrDataNotFound represents the data cannot be found.
	ErrDataNotFound = DfError{codeDataNotFound, "data not found"}

	// ErrEmptyValue represents the value is empty or nil.
	ErrEmptyValue = DfError{codeEmptyValue, "empty value"}

	// ErrInvalidValue represents the value is invalid.
	ErrInvalidValue = DfError{codeInvalidValue, "invalid value"}

	// ErrNotInitialized represents the object is not initialized.
	ErrNotInitialized = DfError{codeNotInitialized, "not initialized"}

	// ErrConvertFailed represents failed to convert.
	ErrConvertFailed = DfError{codeConvertFailed, "convert failed"}

	// ErrRangeNotSatisfiable represents the length of file is insufficient.
	ErrRangeNotSatisfiable = DfError{codeRangeNotSatisfiable, "range not satisfiable"}
)
View Source
var (
	// ErrSystemError represents the error is a system error.
	ErrSystemError = DfError{codeSystemError, "system error"}

	// ErrCDNFail represents the cdn status is fail.
	ErrCDNFail = DfError{codeCDNFail, "cdn status is fail"}

	// ErrCDNWait represents the cdn status is wait.
	ErrCDNWait = DfError{codeCDNWait, "cdn status is wait"}

	// ErrPeerWait represents the peer should wait.
	ErrPeerWait = DfError{codePeerWait, "peer should wait"}

	// ErrUnknownError represents the error should not happen
	// and the cause of that is unknown.
	ErrUnknownError = DfError{codeUnknownError, "unknown error"}

	// PeerContinue represents the peer should wait.
	PeerContinue = DfError{codePeerContinue, "peer continue"}

	// ErrURLNotReachable represents the url is a not reachable.
	ErrURLNotReachable = DfError{codeURLNotReachable, "url not reachable"}

	// ErrTaskIDDuplicate represents the task id is in conflict.
	ErrTaskIDDuplicate = DfError{codeTaskIDDuplicate, "taskId conflict"}

	// ErrAuthenticationRequired represents the authentication is required.
	ErrAuthenticationRequired = DfError{codeAuthenticationRequired, "authentication required"}
)

Functions

func IsAuthenticationRequired

func IsAuthenticationRequired(err error) bool

IsAuthenticationRequired checks the error is an AuthenticationRequired error or not.

func IsCDNFail

func IsCDNFail(err error) bool

IsCDNFail checks the error is CDNFail or not.

func IsCDNWait

func IsCDNWait(err error) bool

IsCDNWait checks the error is CDNWait or not.

func IsConvertFailed

func IsConvertFailed(err error) bool

IsConvertFailed checks the error is a conversion error or not.

func IsDataNotFound

func IsDataNotFound(err error) bool

IsDataNotFound checks the error is the data cannot be found.

func IsEmptyValue

func IsEmptyValue(err error) bool

IsEmptyValue checks the error is the value is empty or nil.

func IsInvalidValue

func IsInvalidValue(err error) bool

IsInvalidValue checks the error is the value is invalid or not.

func IsNilError

func IsNilError(err error) bool

IsNilError checks the error is nil or not.

func IsNotInitialized

func IsNotInitialized(err error) bool

IsNotInitialized checks the error is the object is not initialized or not.

func IsPeerContinue

func IsPeerContinue(err error) bool

IsPeerContinue checks the error is PeerContinue or not.

func IsPeerWait

func IsPeerWait(err error) bool

IsPeerWait checks the error is PeerWait or not.

func IsRangeNotSatisfiable

func IsRangeNotSatisfiable(err error) bool

IsRangeNotSatisfiable checks the error is a range not exist error or not.

func IsSystemError

func IsSystemError(err error) bool

IsSystemError checks the error is a system error or not.

func IsTaskIDDuplicate

func IsTaskIDDuplicate(err error) bool

IsTaskIDDuplicate checks the error is a TaskIDDuplicate error or not.

func IsURLNotReachable

func IsURLNotReachable(err error) bool

IsURLNotReachable checks the error is a url not reachable or not.

func IsUnknowError

func IsUnknowError(err error) bool

IsUnknowError checks the error is UnknowError or not.

Types

type DfError

type DfError struct {
	Code int
	Msg  string
}

DfError represents a Dragonfly error.

func New

func New(code int, msg string) *DfError

New function creates a DfError.

func Newf

func Newf(code int, format string, a ...interface{}) *DfError

Newf function creates a DfError with a message according to a format specifier.

func (DfError) Error

func (s DfError) Error() string

type ErrAssertFunc added in v1.0.0

type ErrAssertFunc func(err error) bool

type HTTPError added in v1.0.1

type HTTPError struct {
	Code int
	Msg  string
}

func NewHTTPError added in v1.0.1

func NewHTTPError(code int, msg string) *HTTPError

NewHTTPError function creates a HTTPError.

func (HTTPError) Error added in v1.0.1

func (s HTTPError) Error() string

Error function implements the interface of error.Error().

func (HTTPError) HTTPCode added in v1.0.1

func (s HTTPError) HTTPCode() int

HTTPCode return the http code.

Jump to

Keyboard shortcuts

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