Add error logging for invalid model errors
This commit is contained in:
parent
f337750c35
commit
9947104b77
|
@ -16,6 +16,7 @@
|
||||||
package handler
|
package handler
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
"github.com/labstack/echo/v4"
|
"github.com/labstack/echo/v4"
|
||||||
"net/http"
|
"net/http"
|
||||||
)
|
)
|
||||||
|
@ -27,7 +28,11 @@ func (c *WebHandler) CreateWeb(ctx echo.Context) error {
|
||||||
|
|
||||||
// Get the object & bind params to struct
|
// Get the object & bind params to struct
|
||||||
if err := ctx.Bind(currentStruct); err != nil {
|
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."))
|
||||||
}
|
}
|
||||||
|
|
||||||
// Validate the struct
|
// Validate the struct
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
package handler
|
package handler
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
"github.com/labstack/echo/v4"
|
"github.com/labstack/echo/v4"
|
||||||
"net/http"
|
"net/http"
|
||||||
)
|
)
|
||||||
|
@ -32,7 +33,11 @@ func (c *WebHandler) DeleteWeb(ctx echo.Context) error {
|
||||||
|
|
||||||
// Bind params to struct
|
// Bind params to struct
|
||||||
if err := ctx.Bind(currentStruct); err != nil {
|
if err := ctx.Bind(currentStruct); err != nil {
|
||||||
return echo.NewHTTPError(http.StatusBadRequest, "Invalid URL param.")
|
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 if the user has the right to delete
|
// Check if the user has the right to delete
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
package handler
|
package handler
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
"github.com/labstack/echo/v4"
|
"github.com/labstack/echo/v4"
|
||||||
"math"
|
"math"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
@ -34,7 +35,11 @@ func (c *WebHandler) ReadAllWeb(ctx echo.Context) error {
|
||||||
|
|
||||||
// Get the object & bind params to struct
|
// Get the object & bind params to struct
|
||||||
if err := ctx.Bind(currentStruct); err != nil {
|
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."))
|
||||||
}
|
}
|
||||||
|
|
||||||
// Pagination
|
// Pagination
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
package handler
|
package handler
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
"github.com/labstack/echo/v4"
|
"github.com/labstack/echo/v4"
|
||||||
"net/http"
|
"net/http"
|
||||||
)
|
)
|
||||||
|
@ -27,7 +28,11 @@ func (c *WebHandler) ReadOneWeb(ctx echo.Context) error {
|
||||||
|
|
||||||
// Get the object & bind params to struct
|
// Get the object & bind params to struct
|
||||||
if err := ctx.Bind(currentStruct); err != nil {
|
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
|
// Check rights
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
package handler
|
package handler
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
"github.com/labstack/echo/v4"
|
"github.com/labstack/echo/v4"
|
||||||
"net/http"
|
"net/http"
|
||||||
)
|
)
|
||||||
|
@ -28,7 +29,11 @@ func (c *WebHandler) UpdateWeb(ctx echo.Context) error {
|
||||||
|
|
||||||
// Get the object & bind params to struct
|
// Get the object & bind params to struct
|
||||||
if err := ctx.Bind(currentStruct); err != nil {
|
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."))
|
||||||
}
|
}
|
||||||
|
|
||||||
// Validate the struct
|
// Validate the struct
|
||||||
|
|
Loading…
Reference in New Issue