Documentation
¶
Index ¶
- type Error
- type Errors
- type ExtError
- func NewBadRequestError(err error) ExtError
- func NewError(err error, code int, message, field string) ExtError
- func NewForbiddenError(err error) ExtError
- func NewInternalServerErrorError(err error) ExtError
- func NewNotFoundError(err error, field string) ExtError
- func NewUnauthorizedError(err error) ExtError
- func NewUnprocessableEntityError(err error, field string) ExtError
- type ExtErrors
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Error ¶
type Error struct {
// Code contains info about HTTP code
// that could be sent in the status of the HTTP response.
Code int `json:"-"`
// Message contains error message if any.
Message string `json:"message,omitempty"`
// Description contains detailed error information if any.
Description string `json:"description,omitempty"`
// Field describes in which field an error has occurred if any.
// For example JSON field in the HTTP request body.
// Typically is used for pointing an invalid field during validation.
Field string `json:"field,omitempty"`
}
Error contains extended error information.
func (Error) ErrDescription ¶
func (Error) ErrMessage ¶
func (Error) MarshalJSON ¶
type Errors ¶
type Errors struct {
Errs []ExtError `json:"errors"`
}
Errors represents multiple errors occurred. Useful for validation errors when required to show all errors at once.
func (Errors) MarshalJSON ¶
type ExtError ¶
type ExtError interface {
error
json.Marshaler
// HTTPCode contains info about HTTP code
// that could be sent in the status of the HTTP response.
HTTPCode() int
// ErrMessage contains error message if any.
ErrMessage() string
// ErrDescription returns error detailed info.
ErrDescription() string
// ErrField describes in which field an error has occurred if any.
// For example JSON field in the HTTP request body.
// Typically is used for pointing an invalid field during validation.
ErrField() string
}
ExtError describes extended error. Can be used in the same way as basic error.
func NewBadRequestError ¶
func NewForbiddenError ¶
func NewNotFoundError ¶
func NewUnauthorizedError ¶
type ExtErrors ¶
type ExtErrors interface {
error
json.Marshaler
// Add adds new ExtError to the slice.
Add(...ExtError)
// Errors returns the slice of ExtError for future processing.
Errors() []ExtError
// Len returns current number of added errors.
Len() int
}
func NewExtErrors ¶
func NewExtErrors() ExtErrors
NewExtErrors returns usage ready instance of ExtErrors.
func NewExtErrorsWithCap ¶
NewExtErrorsWithCap returns instance of ExtErrors with specified capacity of underlying slice.
Click to show internal directories.
Click to hide internal directories.