errors

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2019 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Cause

func Cause(err error) error

Cause returns a cause of Error if the cause exists. The function returns the original error if it is not an instance of Error.

func Match

func Match(got, want error) bool

Match returns true when specified errors are similar, and false when they are not. The errors are considered similar when they have the type "Error", and values of fields "kind" and "param" of the "want" error equal to values of the same fields of the "got" error.

Types

type Error

type Error struct {
	Kind Kind
	// contains filtered or unexported fields
}

Error is an error's wrapper allows to add some context to an underlying error. and returns a pretty formatted error's message.

func New

func New(args ...interface{}) *Error

New returns a new Error constructed from its arguments. The type of each argument determines its meaning. If more than one argument of a given type is presented, only the last one is recorded.

The types are:

errKind
	The class of error, such as IO error.
errParam
	A business object's location with which the error happened.
string
	Treated as an error message.

Arguments having another type is treated as the message's parameters. We recommend to place them at the end of argument's list to avoid confusing.

func Wrap

func Wrap(err error, msg string, params ...interface{}) *Error

Wrap returns a new error that wraps the specified error with a message.

func (*Error) Error

func (e *Error) Error() string

type Kind

type Kind string

Kind describes an error kind.

const (
	// KindOther is a kind for an untyped errors.
	// This kind is used by default when a error kind is not specified.
	KindOther Kind = ""
	// KindEndpointMissed is a kind of an error that happens when OpenID Connect endpoint is not specified.
	KindEndpointMissed Kind = "endpoint_is_missed"
	// KindEndpointInvalid is a kind of an error that happens when OpenID Connect endpoint is invalid.
	KindEndpointInvalid Kind = "endpoint_is_invalid"
	// KindClientIDMissed is a kind of an error that happens when OpenID Connect client ID is not specified.
	KindClientIDMissed Kind = "client_id_is_missed"
	// KindRedirectURIMissed is a kind of an error that happens when OpenID Connect client's redirect URI is not specified.
	KindRedirectURIMissed Kind = "redirect_uri_is_missed"
	// KindScopesMissed is a kind of an error that happens when OpenID Connect scopes are not specified.
	KindScopesMissed Kind = "scopes_are_missed"
	// KindIDTokenMissed is a kind of an error that happens when ID token is not specified.
	KindIDTokenMissed Kind = "id_token_is_missed"
	// KindUsernameMissed is a kind of an error that happens when a username is not specified.
	KindUsernameMissed Kind = "username_is_missed"
	// KindUsernameFieldMissed is a kind of an error that happens when a username field's selector is not specified.
	KindUsernameFieldMissed Kind = "username_field_selector_is_missed"
	// KindUsernameFieldInvalid is a kind of an error that happens when a username field's selector matches to an invalid form element.
	KindUsernameFieldInvalid Kind = "username_field_selector_is_invalid"
	// KindPasswordFieldMissed is a kind of an error that happens when a password field's selector is not specified.
	KindPasswordFieldMissed Kind = "password_field_selector_is_missed"
	// KindPasswordFieldInvalid is a kind of an error that happens when a password field's selector matches to an invalid form element.
	KindPasswordFieldInvalid Kind = "password_field_selector_is_invalid"
	// KindSubmitButtonMissed is a kind of an error that happens when a submit button's selector is not specified.
	KindSubmitButtonMissed Kind = "submit_button_selector_is_missed"
	// KindSubmitButtonInvalid is a kind of an error that happens when a submit button's selector matches to an invalid form element.
	KindSubmitButtonInvalid Kind = "submit_button_selector_is_invalid"
	// KindErrorMessageMissed is a kind of an error that happens when an error message's selector is not specified.
	KindErrorMessageMissed Kind = "error_message_selector_is_missed"
	// KindOIDCError is a kind of an error that is an OpenID Connect errors.
	KindOIDCError Kind = "openid_connect_error"
	// KindLoginError is a kind of an error that happens when authentication failed, for example, when username or password are invalid.
	KindLoginError Kind = "login_error"
	// KindTimeout is a kind of an error that happens when page loading exceeds a timeout.
	KindTimeout Kind = "timeout"
)

func (Kind) String

func (k Kind) String() string

Jump to

Keyboard shortcuts

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