Documentation ¶
Index ¶
- Variables
- func BaseError(err error) error
- func Combine(l, r error) error
- func Errorf(temp string, args ...interface{}) error
- func Friendlyf(err error, format string, args ...interface{}) error
- func New(text string) error
- func NewInvalidClientError(err error) error
- func NewInvalidTokenError(err error) error
- func NewRequestError(err error) error
- func NewServerError(err error) error
- func NewUnsupportedGrantError(grant string) error
- func NewUnsupportedResponseError(responseType string) error
- func UserFriendlyMessage(err error) string
- func UserFriendlyStructure(err error) interface{}
- func Wrap(err error, opts ...Option) error
- func WrapWithFriendlyStructure(err error, structure interface{}) error
- type OAuthError
- type Option
- type UCError
Constants ¶
This section is empty.
Variables ¶
var ErrIncorrectUsernamePassword = OAuthError{ ErrorType: "invalid_grant", ErrorDesc: "incorrect username or password", Code: http.StatusBadRequest, }
ErrIncorrectUsernamePassword indicates a bad username or password.
var ErrInvalidAuthHeader = OAuthError{ ErrorType: "invalid_token", ErrorDesc: "invalid 'Authorization' header", Code: http.StatusUnauthorized, }
ErrInvalidAuthHeader indicates a bad HTTP Authorization header in an auth'd request.
var ErrInvalidAuthorizationCode = OAuthError{ ErrorType: "invalid_grant", ErrorDesc: "invalid code", Code: http.StatusBadRequest, }
ErrInvalidAuthorizationCode indicates a bad authorization code.
var ErrInvalidClientSecret = OAuthError{ ErrorType: "invalid_grant", ErrorDesc: "invalid client secret", Code: http.StatusBadRequest, }
ErrInvalidClientSecret indicates a bad client_secret.
var ErrInvalidCodeVerifier = OAuthError{ ErrorType: "invalid_grant", ErrorDesc: "invalid code verifier", Code: http.StatusBadRequest, }
ErrInvalidCodeVerifier indicates a bad code_verifier argument in a Authorization Code w/PKCE login.
Functions ¶
func Combine ¶ added in v0.4.0
Combine lets you merge multiple errors and return them all (eg. 2 of 5 in a batch failed) TODO: write some tests, fix up output nicely
func NewInvalidClientError ¶
NewInvalidClientError returns an error signifying a bad client ID.
func NewInvalidTokenError ¶
NewInvalidTokenError returns an error signifying a bad token of some kind.
func NewRequestError ¶
NewRequestError returns a new bad request error.
func NewServerError ¶
NewServerError returns a new internal server error.
func NewUnsupportedGrantError ¶
NewUnsupportedGrantError returns a new error signifying an unsupported OAuth `grant_type`.
func NewUnsupportedResponseError ¶
NewUnsupportedResponseError returns a new error signifying an unsupported OAuth `response_type`.
func UserFriendlyMessage ¶
UserFriendlyMessage is just a simple wrapper to handle casting error -> ucError
func UserFriendlyStructure ¶ added in v0.3.0
func UserFriendlyStructure(err error) interface{}
UserFriendlyStructure exposes the structured error data if error is a ucError
func WrapWithFriendlyStructure ¶ added in v0.3.0
WrapWithFriendlyStructure wraps an error with a structured error
Types ¶
type OAuthError ¶
type OAuthError struct { ErrorType string `json:"error"` ErrorDesc string `json:"error_description,omitempty"` Code int `json:"-"` // contains filtered or unexported fields }
OAuthError implements error but can be marshalled to JSON to make an OAuth/OIDC-compliant error. TODO: Should this be a private type like `ucError`?
func (OAuthError) Error ¶
func (o OAuthError) Error() string
Error implements interface `error` for type `OAuthError`
func (OAuthError) Unwrap ¶
func (o OAuthError) Unwrap() error
Unwrap implements errors.Unwrap for errors.Is & errors.As
type Option ¶
type Option interface {
// contains filtered or unexported methods
}
Option defines a way to modify ucerr behavior
func ExtraSkip ¶
func ExtraSkip() Option
ExtraSkip tells Wrap to skip an extra frame in the stack when wrapping an error This allows calls like uchttp.Error() and jsonapi.MarshalError() to call Wrap() and capture the stack frame that actually logged the error (since we rarely call eg, jsonapi.MarshalError(ucerr.Wrap(err)), we lose useful debugging data)