app_errors

package
v0.0.0-...-ce453ac Latest Latest
Warning

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

Go to latest
Published: May 25, 2024 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	UnknownError = NewAppError(
		"UnknownError",
		"",
		0,
		http.StatusTeapot,
	)

	ErrInternalServerError = NewAppError(
		"InternalServerError",
		"internal server error",
		1,
		http.StatusBadRequest)

	ErrSQLExec = NewAppError(
		"SQLError",
		"SQL execution error",
		2,
		http.StatusInternalServerError)

	ErrNotFound = NewAppError(
		"NotFound",
		"entity not found",
		3,
		http.StatusNotFound)

	ErrValidationError = NewAppError(
		"ValidationError",
		"validation error",
		4,
		http.StatusBadRequest)

	ErrParseError = NewAppError(
		"ParseError",
		"parse error",
		5,
		http.StatusBadRequest)

	ErrNoAuthorizationHeader = NewAppError(
		"NoAuthorizationHeader",
		"no authorization header",
		6,
		http.StatusUnauthorized)

	ErrWrongToken = NewAppError(
		"WrongToken",
		"wrong token",
		7,
		http.StatusUnauthorized)
)

Functions

func IsNotFound

func IsNotFound(err error) bool

Types

type AppError

type AppError struct {
	// Наименование ошибки
	Name string `json:"name" validate:"required" example:"NotFound"`
	// Сообщение ошибки
	Message string `json:"message" validate:"required" example:"entity not found"`
	// Код ошибки
	Code int `json:"code" validate:"required" example:"26002"`
	// Статус код ответа
	Status int `json:"status" validate:"required" example:"404"`
	// Начальная ошибка
	InternalError error `json:"-"`
	// Нужно ли логировать ошибку в миддлваре
	IsNotLogging bool `json:"-"`

} //	@AppError

func NewAppError

func NewAppError(name, message string, code, status int) *AppError

func (AppError) DisableLog

func (e AppError) DisableLog() *AppError

func (AppError) Error

func (e AppError) Error() string

func (AppError) SetError

func (e AppError) SetError(error error) *AppError

func (AppError) SetMessage

func (e AppError) SetMessage(message string) *AppError

func (AppError) ToCoreError

func (e AppError) ToCoreError() api.AppError

func (AppError) WrapError

func (e AppError) WrapError(op, msg string) error

Jump to

Keyboard shortcuts

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