Documentation ¶
Overview ¶
Package errors contains all the errors that can be returned by the application This error handled and sent to the client by the framework
You can pass this error to the framework by using the following code:
ctx.Error(errors.ErrRecordNotFound) ctx.Abort() return
Index ¶
- Variables
- func GetValidationErrors(errs validator.ValidationErrors) map[string]ValidationErrorData
- type AggregateVersionMismatch
- type AggregateVersionMismatchParam
- type BadRequest
- type BadRequestParam
- type Forbidden
- type ForbiddenParam
- type Invariant
- type InvariantParam
- type NotFound
- type NotFoundParam
- type Unauthorized
- type UnauthorizedParam
- type ValidationErrorData
Constants ¶
This section is empty.
Variables ¶
var ErrRecordNotFound = NewNotFound(NotFoundParam{})
RecordNotFound is an error that occurs when the record is not found
var ErrValidation = errors.New("validation_error")
ErrValidation is an error that occurs when the request is invalid
Functions ¶
func GetValidationErrors ¶
func GetValidationErrors(errs validator.ValidationErrors) map[string]ValidationErrorData
GetValidationErrors is a function that returns ValidationErrorData
Types ¶
type AggregateVersionMismatch ¶
type AggregateVersionMismatch struct {
// contains filtered or unexported fields
}
AggregateVersionMismatch is an error that occurs when the aggregate version in database is not the same as the aggregate version in the command
func NewAggregateVersionMismatch ¶
func NewAggregateVersionMismatch(param AggregateVersionMismatchParam) AggregateVersionMismatch
func (AggregateVersionMismatch) Code ¶
func (e AggregateVersionMismatch) Code() int
func (AggregateVersionMismatch) Error ¶
func (e AggregateVersionMismatch) Error() string
type AggregateVersionMismatchParam ¶
type AggregateVersionMismatchParam struct { // Code is the status code of the error // // Default to HTTP status code 409 Code int // Msg is the message of the error // // Default to "aggregate_version_mismatch" Msg string }
AggregateVersionMismatchParam is a struct that contains parameters for AggregateVersionMismatch
type BadRequest ¶
type BadRequest struct {
// contains filtered or unexported fields
}
BadRequest is an error that occurs when the request is invalid and cannot be processed
func NewBadRequest ¶
func NewBadRequest(param BadRequestParam) BadRequest
func (BadRequest) Code ¶
func (e BadRequest) Code() int
func (BadRequest) Data ¶
func (e BadRequest) Data() map[string]interface{}
func (BadRequest) Error ¶
func (e BadRequest) Error() string
func (BadRequest) Message ¶
func (e BadRequest) Message() string
type BadRequestParam ¶
type BadRequestParam struct { // Code is the status code of the error // // Default to HTTP status code 400 Code int // Message is the message of the error // // Default to "bad_request" Message string // Data is the additional data of the error // // Default to nil Data map[string]interface{} }
BadRequestParam is a struct that contains parameters for BadRequestError
type Forbidden ¶
type Forbidden struct {
// contains filtered or unexported fields
}
Forbidden is an error that occurs when the request is forbidden
func NewForbidden ¶
func NewForbidden(param ForbiddenParam) Forbidden
func (Forbidden) IsDetailRemovedInProd ¶
type ForbiddenParam ¶
type ForbiddenParam struct { // Code is the status code of the error // // Default to HTTP status code 403 Code int // Message is the message of the error // // Default to "forbidden" Message string // Details is the details of the error // // Default to "" Details string // ShowDetailsInProduction is a flag that indicates whether to remove details in production // // Default to false ShowDetailsInProduction bool }
type Invariant ¶
type Invariant struct {
// contains filtered or unexported fields
}
Invariant is an error that occurs when invariant is violated
func NewInvariant ¶
func NewInvariant(param InvariantParam) Invariant
type InvariantParam ¶
type InvariantParam struct { // Code is the status code of the error // // Default to HTTP status code 400 Code int // Message is the message of the error // // Default to "invariant_error" Message string // Details is the details of the error // // Default to "" Details string }
InvariantParam is a struct that contains parameters for InvariantError
type NotFound ¶
type NotFound struct {
// contains filtered or unexported fields
}
NotFound is an error that occurs when the resource is not found
func NewNotFound ¶
func NewNotFound(param NotFoundParam) NotFound
type NotFoundParam ¶
type Unauthorized ¶
type Unauthorized struct {
// contains filtered or unexported fields
}
Unauthorized is an error that occurs when the request is unauthorized
func NewUnauthorized ¶
func NewUnauthorized(param UnauthorizedParam) Unauthorized
func (Unauthorized) Error ¶
func (e Unauthorized) Error() string
type UnauthorizedParam ¶
type UnauthorizedParam struct { // // Default to HTTP status code 401 Code int }
type ValidationErrorData ¶
ValidationErrorData is a struct that contains data for validation error