errors

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Oct 4, 2025 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

View Source
const (
	InternalServerError = "internal server error"
	BadRequest          = "bad request"
	NotFound            = "not_found"
	UnauthorizedError   = "unauthorized"

	UnauthorizedErrorCode   = 401
	InvalidDataCode         = 402
	ForbiddenErrorCode      = 403
	InternalServerErrorCode = 500
	NotFoundErrorCode       = 404
)

Variables

View Source
var (
	ErrDataNotFound = errors.New("data not found")
	ErrUnauthorized = errors.New("unauthorized")
	ErrForbidden    = errors.New("forbidden")
	ErrInternal     = errors.New("internal error")
)

Functions

This section is empty.

Types

type AppError

type AppError struct {
	Code         int    `json:"code"`    // HTTP статус код
	Message      string `json:"message"` // Сообщение для клиента
	Err          error  `json:"-"`       // Внутренняя ошибка, не для клиента
	IsUserFacing bool   `json:"-"`       // Флаг, указывающий, можно ли показывать `Err`
}

AppError представляет собой стандартизированную структуру ошибки для API

func NewAppError

func NewAppError(httpCode int, message string, err error, isUserFacing bool) *AppError

NewAppError создает новый экземпляр AppError

func (*AppError) Error

func (a *AppError) Error() string

Jump to

Keyboard shortcuts

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