Documentation ¶
Index ¶
- Constants
- func AddPaginationHeaders(w http.ResponseWriter, offset, limit, totalCnt uint64)
- func AddTotalVpHeader(w http.ResponseWriter, vp float32)
- func HandleError(err Error, w http.ResponseWriter)
- func IsInternalError(err error) bool
- func ParseError(err Error) map[string]interface{}
- type BaseError
- type Error
- type ErrorMessage
- type InternalError
- type NotFoundError
- type PermissionDeniedError
- type RateLimitedError
- type UnprocessableEntityError
- type ValidationError
Constants ¶
View Source
const ( HeaderTotalCount = "X-Total-Count" HeaderTotalVp = "X-Total-Vp" HeaderCurrentOffset = "X-Offset" HeaderLimit = "X-Limit" )
View Source
const (
GeneralErrorKey = "_"
)
Variables ¶
This section is empty.
Functions ¶
func AddPaginationHeaders ¶
func AddPaginationHeaders(w http.ResponseWriter, offset, limit, totalCnt uint64)
func AddTotalVpHeader ¶ added in v0.1.3
func AddTotalVpHeader(w http.ResponseWriter, vp float32)
func HandleError ¶
func HandleError(err Error, w http.ResponseWriter)
func IsInternalError ¶
IsInternalError returns false when the error is caused by invalid request data or by other mismatches caused by an user. It can be used to determine whether the error should be logged. If the function returns false, the error shouldn't be logged.
func ParseError ¶
ParseError determines the error type and creates a map with the error description.
Types ¶
type Error ¶
func ResolveError ¶
type ErrorMessage ¶
func MissedValueError ¶
func MissedValueError(message string) ErrorMessage
func WrongFormatError ¶
func WrongFormatError(message string) ErrorMessage
func WrongValueError ¶
func WrongValueError(message string) ErrorMessage
func (ErrorMessage) Error ¶
func (e ErrorMessage) Error() string
type InternalError ¶
type InternalError struct {
BaseError
}
func NewInternalError ¶
func NewInternalError() *InternalError
func (*InternalError) GetHTTPStatus ¶
func (e *InternalError) GetHTTPStatus() int
func (*InternalError) PublicMessage ¶
func (e *InternalError) PublicMessage() string
type NotFoundError ¶
type NotFoundError struct {
BaseError
}
func NewNotFoundError ¶
func NewNotFoundError() *NotFoundError
func (*NotFoundError) GetHTTPStatus ¶
func (e *NotFoundError) GetHTTPStatus() int
func (*NotFoundError) PublicMessage ¶
func (e *NotFoundError) PublicMessage() string
type PermissionDeniedError ¶
type PermissionDeniedError struct {
BaseError
}
func NewPermissionDeniedError ¶
func NewPermissionDeniedError() *PermissionDeniedError
func (*PermissionDeniedError) GetHTTPStatus ¶
func (e *PermissionDeniedError) GetHTTPStatus() int
func (*PermissionDeniedError) PublicMessage ¶
func (e *PermissionDeniedError) PublicMessage() string
type RateLimitedError ¶
func NewRateLimitedError ¶
func NewRateLimitedError(retryAfter int) *RateLimitedError
func (*RateLimitedError) GetHTTPStatus ¶
func (e *RateLimitedError) GetHTTPStatus() int
func (*RateLimitedError) PublicMessage ¶
func (e *RateLimitedError) PublicMessage() string
type UnprocessableEntityError ¶
type UnprocessableEntityError struct {
ValidationError
}
func NewNotAcceptableError ¶
func NewNotAcceptableError(details ...map[string]ErrorMessage) *UnprocessableEntityError
func (*UnprocessableEntityError) GetHTTPStatus ¶
func (e *UnprocessableEntityError) GetHTTPStatus() int
func (*UnprocessableEntityError) PublicMessage ¶
func (e *UnprocessableEntityError) PublicMessage() string
type ValidationError ¶
type ValidationError struct { BaseError // contains filtered or unexported fields }
func NewValidationError ¶
func NewValidationError(details ...map[string]ErrorMessage) *ValidationError
func (*ValidationError) Errors ¶
func (e *ValidationError) Errors() map[string]ErrorMessage
func (*ValidationError) GetHTTPStatus ¶
func (e *ValidationError) GetHTTPStatus() int
func (*ValidationError) PublicMessage ¶
func (e *ValidationError) PublicMessage() string
Click to show internal directories.
Click to hide internal directories.