errorhandler

package
v1.0.20 Latest Latest
Warning

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

Go to latest
Published: Apr 6, 2022 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ErrorObject

type ErrorObject struct {
	Error      error
	StatusCode int
	Lang       Lang
}

func LoadLanguages

func LoadLanguages(messages map[string]map[string]string, context string) ErrorObject

LoadLanguages função principal necessária para carregar as mensagens de erro que serão utilizadas

func (*ErrorObject) BuildErrorMessage

func (e *ErrorObject) BuildErrorMessage(idiom, messageKey string, replacements []string) *ErrorObject

BuildErrorMessage responsável por atribuir os valores que serão usados para criar uma mensagem de erro internacionalizada

func (*ErrorObject) CreateErrorResponse

func (e *ErrorObject) CreateErrorResponse(w http.ResponseWriter, err error, statusCode int)

CreateErrorResponse constrói a estrutura padrão de mensagem de erro e escreve a resposta no response

func (*ErrorObject) GetErrorMessage

func (e *ErrorObject) GetErrorMessage() string

GetErrorMessage retorna a mensagem de erro como string

func (*ErrorObject) SetError

func (e *ErrorObject) SetError(err error, statusCode int) *ErrorObject

SetError função genérica para ser utilizada caso NÃO seja necessária mensagem customizada traduzida

type ErrorResponse

type ErrorResponse struct {
	Error detail `json:"error"`
}

type Lang

type Lang struct {
	Idiom        string
	Replacements []string
	MessageKey   string
	Context      string
	MessagesLang map[string]map[string]string
}

func (*Lang) HasLang

func (l *Lang) HasLang() bool

HasLang valida se foram carregadas as lang necessárias

Jump to

Keyboard shortcuts

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