Documentation
¶
Index ¶
- Variables
- type APIError
- func BadRequest(message string, err error) *APIError
- func Forbidden(message string, err error) *APIError
- func InternalServer(message string, err error) *APIError
- func New(code int, message string, err error) *APIError
- func NotFound(resource string, err error) *APIError
- func Unauthorized(message string, err error) *APIError
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrNotFound = errors.New("recurso não encontrado") ErrBadRequest = errors.New("requisição inválida") ErrForbidden = errors.New("acesso negado") ErrInternalServer = errors.New("erro interno do servidor") 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 InternalServer ¶
InternalServer cria um erro 500
func Unauthorized ¶
Unauthorized cria um erro 401
func (*APIError) WithDetails ¶
WithDetails adiciona detalhes ao erro
Click to show internal directories.
Click to hide internal directories.