errors

package
v0.0.0-...-7dc96ab Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2023 License: GPL-3.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var AccessLevel = NewCustom(401, "Accesos Insuficientes")

AccessLevel es el error de seguridad, el usuario no esta autorizado para acceder al recurso

View Source
var AlreadyExist = NewCustom(400, "Already exist")

AlreadyExist cuando no se puede ingresar un registro a la db

View Source
var ErrID = NewValidationField("id", "Invalid")

ErrID el id del documento es invalido

View Source
var Internal = NewCustom(500, "Internal server error")

Internal esta aplicación no sabe como manejar el error

View Source
var NotFound = NewCustom(400, "Document not found")

NotFound cuando un registro no se encuentra en la db

View Source
var Unauthorized = NewCustom(401, "Unauthorized")

Unauthorized el usuario no esta autorizado al recurso

Functions

This section is empty.

Types

type Custom

type Custom interface {
	Status() int
	Error() string
}

Custom es una interfaz para definir errores custom

type ErrCustom

type ErrCustom struct {
	Message string `json:"error"`
	// contains filtered or unexported fields
}

ErrCustom es un error personalizado para http

func NewCustom

func NewCustom(status int, message string) *ErrCustom

NewCustom creates a new errCustom

func (*ErrCustom) Error

func (e *ErrCustom) Error() string

func (*ErrCustom) Status

func (e *ErrCustom) Status() int

Status http status code

type ErrField

type ErrField struct {
	Path    string `json:"path"`
	Message string `json:"message"`
}

ErrField define un campo inválido. path y mensaje de error

type ErrValidation

type ErrValidation struct {
	Messages []ErrField `json:"messages"`
}

ErrValidation es un error de validaciones de parameteros o de campos

func (*ErrValidation) Add

func (e *ErrValidation) Add(path string, message string) Validation

Add agrega errores a un validation error

func (*ErrValidation) Error

func (e *ErrValidation) Error() string

func (*ErrValidation) Size

func (e *ErrValidation) Size() int

Size devuelve la cantidad de errores

type Validation

type Validation interface {
	Add(path string, message string) Validation
	Size() int
	Error() string
}

Validation es una interfaz para definir errores custom Validation es un error de validaciones de parameteros o de campos

func NewValidation

func NewValidation() Validation

NewValidation crea un error de validación para un solo campo

func NewValidationField

func NewValidationField(field string, err string) Validation

NewValidationField crea un error de validación para un solo campo

Jump to

Keyboard shortcuts

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