Documentation ¶
Overview ¶
backend-errors is a package developed and used by cook4U. It is made so that every micro service can use the same errors methods.
Index ¶
- Variables
- func BadInputJSON(name string, reason string) []byte
- func BadInputJSONFromType(name string, errorType string) []byte
- func BadInputsJSON(fields map[string]string) []byte
- func BadInputsJSONFromType(fields map[string]string) []byte
- func GetJSONFieldName(object interface{}, fieldName string) (string, error)
- func InternalServerError(ctx *fiber.Ctx, err error)
- func ParseBodyJSON(ctx *fiber.Ctx, object interface{}) bool
- type BadInput
- type ErrorType
- type KafkaErrorMessage
Constants ¶
This section is empty.
Variables ¶
Functions ¶
func BadInputJSON ¶
BadInputJSON is simply a call to BadInputsJSON to create a single bad input error. It returns the JSON of the struct BadInput in []byte.
func BadInputJSONFromType ¶
BadInputJSONFromType is simply a call to BadInputsJSONFromType to create a single bad input error. It returns the JSON of the struct BadInput in []byte.
func BadInputsJSON ¶
BadInputsJSON creates the error JSON using the struct BadInput. The key of the map given correspond to the Name and the value to the Reason. It returns the JSON in []byte.
func BadInputsJSONFromType ¶
BadInputsJSONFromType create a BadInput JSON from a key and a value corresponding to an ErrorType. It replace the Value with the defined string corresponding to the ErrorType. It returns the JSON in []byte.
func GetJSONFieldName ¶
GetJSONFieldName is used to get the json tag of a given field in a struct
func InternalServerError ¶
func InternalServerError(ctx *fiber.Ctx, err error)
InternalServerError set a 500 http error and log the error.
func ParseBodyJSON ¶
func ParseBodyJSON(ctx *fiber.Ctx, object interface{}) bool
ParseBodyJSON parse and validate a body contained in the fiber context to the given object If an error occur, the correct http error is called and false is returned The validator errors messages are using BadInputsJSONFromType