Documentation
¶
Index ¶
- Variables
- func GRPCResponse(err error) error
- func HTTPResponse(c *gin.Context, err error)
- func Is(err, target error) bool
- func RegisterTagNameFunc(fld reflect.StructField) string
- func SetTranslators(validate *validator.Validate)
- type APPError
- func (e APPError) Error() string
- func (e APPError) WithApperr(err *APPError) *APPError
- func (e APPError) WithContext(context string) *APPError
- func (e APPError) WithError(err error) *APPError
- func (e APPError) WithId(id string) *APPError
- func (e APPError) WithShowMessageBanner(showMessageBanner bool) *APPError
- func (e APPError) WithStatus(status Code) *APPError
- func (e APPError) WithText(text string) *APPError
- func (e APPError) WithTitle(title string) *APPError
- func (e APPError) WithTranslate(translate Translate) *APPError
- func (e APPError) WithTranslateArgs(args ...interface{}) *APPError
- type Code
- type Translate
- type ValidateError
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrSyntax = New(StatusInternalServerError, "syntax").WithTranslate(Translate{ "ru": "Неверный запрос", }) ErrValidation = New(StatusBadRequest, "validation").WithTranslate(Translate{ "ru": "Ошибка валидации", }) ErrEmptyData = New(StatusInternalServerError, "empty_data").WithTranslate(Translate{ "ru": "Пустые данные", }) ErrInternal = New(StatusInternalServerError, "internal").WithTranslate(Translate{ "ru": "Ошибка сервера", }) ErrForbidden = New(StatusForbidden, "forbidden").WithTranslate(Translate{ "ru": "Нет доступа", }) ErrUnauthenticated = New(StatusUnauthenticated, "unauthorized").WithTranslate(Translate{ "ru": "Ошибка аутентификации", }) ErrNotFound = New(StatusNotFound, "not_found").WithTranslate(Translate{ "ru": "Не найдено", }) ErrServerIsNotAvailable = New(StatusInternalServerError, "server_is_not_available").WithTranslate(Translate{ "ru": "Сервер недоступен", }) Err404 = New(StatusInternalServerError, "invalid_request").WithTranslate(Translate{ "ru": "Неверный запрос", }) )
Functions ¶
func GRPCResponse ¶
func HTTPResponse ¶
HTTPResponse writes an error response to client
func RegisterTagNameFunc ¶
func RegisterTagNameFunc(fld reflect.StructField) string
func SetTranslators ¶
Types ¶
type APPError ¶
type APPError struct {
ID string `json:"id"`
Title string `json:"title"`
Text string `json:"text"`
Context string `json:"context"`
ShowMessageBanner bool `json:"show_message_banner"`
MethodID string `json:"-"`
Translate Translate `json:"-"`
TranslateArgs []interface{} `json:"-"`
Status Code `json:"-"`
Err error `json:"-"`
}
func NewForResponse ¶ added in v1.0.24
func (APPError) WithApperr ¶ added in v1.0.24
func (APPError) WithContext ¶
func (APPError) WithShowMessageBanner ¶
func (APPError) WithStatus ¶
func (APPError) WithTranslate ¶
func (APPError) WithTranslateArgs ¶
type ValidateError ¶ added in v1.0.1
Click to show internal directories.
Click to hide internal directories.