// ErrorHandler generates an error message and saves it to the log
// The logger must be previously installed in the Echo context.
ErrorHandler generates an error message and saves it to the log
The logger must be previously installed in the Echo context.
// ErrorHandler generates an error message and saves it to the log // The logger must be previously installed in the Echo context .
func ErrorHandler(err error, c echo.Context) {
	req := c.Request()
	res := c.Response()
	reqBody := []byte{}
	if req.Body != nil { 
		reqBody, _ = ioutil.ReadAll(req.Body)
	}
	c.Request().Body = ioutil.NopCloser(bytes.NewBuffer(reqBody))
	id := req.Header.Get(echo.HeaderXRequestID)
	if id == "" {
		id = res.Header().Get(echo.HeaderXRequestID)
	}
	fields := []zapcore.Field{
		zap.Error(err),
		zap.Any("request", reqBody),
	}
	zap.L().Error("Server error", fields...)
	return
}
func ErrorHandler ( err error , c echo . Context ) { req := c . Request ( ) res := c . Response ( ) reqBody := [ ] byte { } if req . Body != nil { reqBody , _ = ioutil . ReadAll ( req . Body ) } c . Request ( ) . Body = ioutil . NopCloser ( bytes . NewBuffer ( reqBody ) ) id := req . Header . Get ( echo . HeaderXRequestID ) if id == " " { id = res . Header ( ) . Get ( echo . HeaderXRequestID ) } fields := [ ] zapcore . Field { zap . Error ( err ) , zap . Any ( " " , reqBody ) , } zap . L ( ) . Error ( " " , fields ... ) return }
ErrorHandler generates an error message and saves it to the log
The logger must be previously installed in the Echo context.
ErrorHandler generates an error message and saves it to the log The logger must be previously installed in the Echo context .
// Read