errors

package
v1.9.2 Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2024 License: MIT Imports: 3 Imported by: 0

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

Constants

This section is empty.

Variables

View Source
var ErrRecordNotFound = NewNotFound(NotFoundParam{})

RecordNotFound is an error that occurs when the record is not found

View Source
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 (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) Details

func (e Forbidden) Details() string

func (Forbidden) Error

func (e Forbidden) Error() string

func (Forbidden) IsDetailRemovedInProd

func (e Forbidden) IsDetailRemovedInProd() bool

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

func (Invariant) Code

func (e Invariant) Code() int

func (Invariant) Details

func (e Invariant) Details() string

func (Invariant) Error

func (e Invariant) Error() string

func (Invariant) Message

func (e Invariant) Message() string

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

func (NotFound) Code

func (e NotFound) Code() int

func (NotFound) Error

func (e NotFound) Error() string

type NotFoundParam

type NotFoundParam struct {
	// Code is the status code of the error
	//
	// Default to HTTP status code 404
	Code int

	// Msg is the message of the error
	//
	// Default to "not_found"
	Msg string
}

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 {
	// Code is the status code of the error
	//
	// Default to HTTP status code 401
	Code int
}

type ValidationErrorData

type ValidationErrorData struct {
	Tag   string `json:"tag"`
	Param string `json:"param"`
}

ValidationErrorData is a struct that contains data for validation error

Jump to

Keyboard shortcuts

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