errors

package
v0.1.9 Latest Latest
Warning

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

Go to latest
Published: Jan 19, 2025 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package errors contains reusable error messages and other helpers for dealing with errors.

Index

Constants

View Source
const (
	MessageInternalServerError = "the server encountered a problem and could not process your request"
	MessageTooManyRequests     = "rate limit exceeded"
	MessageForbidden           = "user has no access to this resource"
)

Variables

View Source
var (
	// ErrFailedValidation is used when validation by [validate.Validator] failed.
	ErrFailedValidation = errors.New("failed validation")
)

Functions

This section is empty.

Types

type BadRequestError

type BadRequestError struct {
	// contains filtered or unexported fields
}

BadRequestError is used to return a bad request response.

func NewBadRequestError

func NewBadRequestError(err error) BadRequestError

NewBadRequestError creates a new BadRequestError.

func (BadRequestError) Error

func (err BadRequestError) Error() string

type ConflictError

type ConflictError struct {
	JSONField string
	// contains filtered or unexported fields
}

ConflictError is used when an existing resource would conflict with a new resource.

func NewConflictError

func NewConflictError(
	resourceName string,
	identifierValue any,
	jsonField string,
) ConflictError

NewConflictError creates a new ConflictError.

func (ConflictError) Error

func (err ConflictError) Error() string

type ErrorDto

type ErrorDto struct {
	Status  int    `json:"status"`
	Error   string `json:"error"`
	Message any    `json:"message"`

} //	@name	ErrorDto

ErrorDto is used to return the error back to the client.

func NewErrorDto

func NewErrorDto(status int, message any) ErrorDto

NewErrorDto creates a new ErrorDto.

type NotFoundError

type NotFoundError struct {
	JSONField string
	// contains filtered or unexported fields
}

NotFoundError is used when a certain resource doesn't exist.

func NewNotFoundError

func NewNotFoundError(
	resourceName string,
	identifierValue any,
	jsonField string,
) NotFoundError

NewNotFoundError creates a new NotFoundError.

func (NotFoundError) Error

func (err NotFoundError) Error() string

type UnauthorizedError

type UnauthorizedError struct {
	// contains filtered or unexported fields
}

UnauthorizedError is used to return an unauthorized response.

func NewUnauthorizedError

func NewUnauthorizedError(err error) UnauthorizedError

NewUnauthorizedError creates a new UnauthorizedError.

func (UnauthorizedError) Error

func (err UnauthorizedError) Error() string

Jump to

Keyboard shortcuts

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