errors

package
v0.0.0-...-2defda7 Latest Latest
Warning

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

Go to latest
Published: Apr 27, 2025 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotFound           = errors.New("recurso não encontrado")
	ErrBadRequest         = errors.New("requisição inválida")
	ErrUnauthorized       = errors.New("não autorizado")
	ErrForbidden          = errors.New("acesso negado")
	ErrInternalServer     = errors.New("erro interno do servidor")
	ErrServiceUnavailable = errors.New("serviço indisponível")
	ErrTimeout            = errors.New("tempo de espera excedido")
	ErrDuplicate          = errors.New("recurso já existe")
)

Tipos de erro comuns

Functions

This section is empty.

Types

type APIError

type APIError struct {
	Code        int         `json:"-"`
	Message     string      `json:"message"`
	Details     interface{} `json:"details,omitempty"`
	OriginalErr error       `json:"-"`
}

APIError representa um erro da API com informações adicionais

func BadRequest

func BadRequest(message string, err error) *APIError

BadRequest cria um erro 400

func Forbidden

func Forbidden(message string, err error) *APIError

Forbidden cria um erro 403

func InternalServer

func InternalServer(message string, err error) *APIError

InternalServer cria um erro 500

func New

func New(code int, message string, err error) *APIError

New cria um novo APIError

func NotFound

func NotFound(resource string, err error) *APIError

NotFound cria um erro 404

func Unauthorized

func Unauthorized(message string, err error) *APIError

Unauthorized cria um erro 401

func (*APIError) Error

func (e *APIError) Error() string

Error implementa a interface error

func (*APIError) Unwrap

func (e *APIError) Unwrap() error

Unwrap permite usar errors.Is e errors.As

func (*APIError) WithDetails

func (e *APIError) WithDetails(details interface{}) *APIError

WithDetails adiciona detalhes ao erro

Jump to

Keyboard shortcuts

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