1
0

Add logging for invalid model errors (#126)

Add logging for invalid model errors

Co-authored-by: kolaente <k@knt.li>
Reviewed-on: https://kolaente.dev/vikunja/api/pulls/126
This commit is contained in:
konrad
2020-01-26 19:40:23 +00:00
parent fc65052ba0
commit a464d1760c
167 changed files with 18301 additions and 7389 deletions

View File

@ -16,6 +16,7 @@
package handler
import (
"fmt"
"github.com/labstack/echo/v4"
"net/http"
)
@ -27,7 +28,11 @@ func (c *WebHandler) ReadOneWeb(ctx echo.Context) error {
// Get the object & bind params to struct
if err := ctx.Bind(currentStruct); err != nil {
return echo.NewHTTPError(http.StatusBadRequest, "No or invalid model provided.")
config.LoggingProvider.Debugf("Invalid model error. Internal error was: %s", err.Error())
if he, is := err.(*echo.HTTPError); is {
return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid model provided. Error was: %s", he.Message))
}
return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid model provided."))
}
// Check rights