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) Combine(err *APPError) *APPError
- func (e APPError) Error() string
- func (e APPError) Translate(lang string) *APPError
- func (e APPError) WithError(err error) *APPError
- func (e APPError) WithShowMessageBanner(showMessageBanner bool) *APPError
- func (e APPError) WithStatus(status Code) *APPError
- func (e APPError) WithTextTranslate(translate Translate) *APPError
- func (e APPError) WithTextTranslateArgs(args ...interface{}) *APPError
- func (e APPError) WithTitleTranslate(translate Translate) *APPError
- func (e APPError) WithTitleTranslateArgs(args ...interface{}) *APPError
- type Code
- type Translate
- type ValidateError
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrSyntax = New(StatusInternalServerError, "syntax_error").WithTextTranslate(Translate{ "ru": "Неверный запрос", }) ErrValidation = New(StatusBadRequest, "validation_error").WithTextTranslate(Translate{ "ru": "Неверный запрос", }) ErrEmptyData = New(StatusInternalServerError, "empty_data_error").WithTextTranslate(Translate{ "ru": "Неверный запрос", }) ErrInternal = New(StatusInternalServerError, "internal_error").WithTextTranslate(Translate{ "ru": "Ошибка сервера", }) ErrForbidden = New(StatusForbidden, "forbidden_error").WithTextTranslate(Translate{ "ru": "Нет доступа", }) ErrUnauthenticated = New(StatusUnauthenticated, "unauthorized_error").WithTextTranslate(Translate{ "ru": "Ошибка аутентификации", }) ErrNotFound = New(StatusNotFound, "not_found_error").WithTextTranslate(Translate{ "ru": "Не найдено", }) ErrServerIsNotAvailable = New(StatusInternalServerError, "server_is_not_available").WithTextTranslate(Translate{ "ru": "Сервер недоступен", }) Err404 = New(StatusInternalServerError, "invalid_request").WithTextTranslate(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:"-"`
TextTranslate Translate `json:"-"`
TextTranslateArgs []interface{} `json:"-"`
TitleTranslate Translate `json:"-"`
TitleTranslateArgs []interface{} `json:"-"`
Status Code `json:"-"`
Err error `json:"-"`
}
func ParseGRPCError ¶ added in v1.0.29
func (APPError) WithShowMessageBanner ¶
func (APPError) WithStatus ¶
func (APPError) WithTextTranslate ¶ added in v1.0.27
func (APPError) WithTextTranslateArgs ¶ added in v1.0.27
func (APPError) WithTitleTranslate ¶ added in v1.0.27
func (APPError) WithTitleTranslateArgs ¶ added in v1.0.27
type ValidateError ¶ added in v1.0.1
Click to show internal directories.
Click to hide internal directories.