response

package
v0.0.0-...-1bd3253 Latest Latest
Warning

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

Go to latest
Published: Feb 2, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// numbering 100-1000
	GeneralCode_UnprocessableEntity   = 100
	GeneralCode_ResourceNotFound      = 101
	GeneralCode_MethodNotAllowed      = 102
	GeneralCode_NotAcceptable         = 103
	GeneralCode_GatewayTimeout        = 104
	GeneralCode_Unspecified           = 105
	GeneralCode_NotHTTPError          = 106
	GeneralCode_InternalHTTPError     = 107
	GeneralCode_ValidationFailedError = 108
	GeneralCode_BodyBindingFailed     = 109
)
View Source
const (
	ValidationCode_FieldRequired           = 1
	ValidationCode_FieldNotEmpty           = 2
	ValidationCode_FieldTypeISO3166_Alpha2 = 3
	ValidationCode_FieldTypeNumeric        = 4
	ValidationCode_FieldOneOf              = 5
	ValidationCode_FieldMaxSign            = 6
	ValidationCode_FieldMaxSigns           = 7
	ValidationCode_FieldMinSign            = 8
	ValidationCode_FieldMinSigns           = 9
	ValidationCode_FieldTypeISO4217        = 10
	ValidationCode_FieldMinDecimal         = 11
	ValidationCode_FieldMinDecimals        = 12
	ValidationCode_FieldMaxDecimal         = 13
	ValidationCode_FieldMaxDecimals        = 14
	// Validator uncompatible errors
	ValidationCode_FieldUnknownTagError = 9998
	ValidationCode_FieldUnknownError    = 9999
)

Field validation error codes Field validation error descriptors

View Source
const (
	ParamsTagOneOf = ":validOptions"
	ParamsTagMin   = ":min"
	ParamsTagMax   = ":max"
)

Field validation param tagsf

Variables

View Source
var (
	ApiErrorUnprocessableEntity  = errors.New(http.StatusUnprocessableEntity, GeneralCode_UnprocessableEntity, "Unprocessable Entity")
	ApiErrorResourceNotFound     = errors.New(http.StatusNotFound, GeneralCode_ResourceNotFound, "Resource not found")
	ApiErrorMethodNotAllowed     = errors.New(http.StatusMethodNotAllowed, GeneralCode_MethodNotAllowed, "Method Not Allowed")
	ApiErrorNotAcceptable        = errors.New(http.StatusNotAcceptable, GeneralCode_NotAcceptable, "Not Acceptable")
	ApiErrorGatewayTimeout       = errors.New(http.StatusGatewayTimeout, GeneralCode_NotHTTPError, "Gateway Timeout")
	ApiErrorUnspecified          = errors.New(http.StatusNotAcceptable, GeneralCode_Unspecified, "Unspecified")
	ApiErrorNotHTTPError         = errors.New(http.StatusNotFound, GeneralCode_NotHTTPError, "Not Http Error")
	ApiErrorInternalServerError  = errors.New(http.StatusInternalServerError, GeneralCode_InternalHTTPError, "Internal Server Error")
	ApiErrorValidationBodyFailed = errors.New(http.StatusBadRequest, GeneralCode_ValidationFailedError, "Validation Failed")
	ApiErrorBodyBindingFailed    = errors.New(http.StatusUnprocessableEntity, GeneralCode_BodyBindingFailed, "Body Binding Failed")
)

Functions

func ApiErrorMapping

func ApiErrorMapping(echoError *echo.HTTPError) errors.CodeMsg

func HttpError

func HttpError(httpStatus int) error

HttpError basic http error

func HttpErrorBodyValidation

func HttpErrorBodyValidation(internalErr error) error

func HttpErrorHandler

func HttpErrorHandler(err error, c echo.Context)

func HttpErrorValidation

func HttpErrorValidation(internalErr error) error

HttpErrorValidation Validation errror with internal error

func HttpErrorValidationWithCode

func HttpErrorValidationWithCode(code errors.CodeMsg, internalErr error) error

HttpErrorValidationWithCode Validation error with internal error

func HttpErrorWithInternal

func HttpErrorWithInternal(httpStatus int, code interface{}, internalErr error) error

HttpErrorWithInternal echo.HttpError has a message interface{} field, which can be used to include the ServiceCode

func HttpWithServiceError

func HttpWithServiceError(httpStatus int, code errors.CodeMsg) error

HttpWithServiceError Make an echo compatible error out of a service error

func ParseFieldError

func ParseFieldError(validationErr validator.FieldError) httpx.InnerError

Types

This section is empty.

Jump to

Keyboard shortcuts

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