Improved error handling
This commit is contained in:
parent
a4137b3d6f
commit
f969593c0a
14 changed files with 345 additions and 177 deletions
|
|
@ -2,6 +2,8 @@ package crud
|
|||
|
||||
import (
|
||||
"code.vikunja.io/api/models"
|
||||
"github.com/labstack/echo"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
// WebHandler defines the webhandler object
|
||||
|
|
@ -12,3 +14,13 @@ type WebHandler struct {
|
|||
models.Rights
|
||||
}
|
||||
}
|
||||
|
||||
// HandleHTTPError does what it says
|
||||
func HandleHTTPError(err error) *echo.HTTPError {
|
||||
if a, has := err.(models.HTTPErrorProcessor); has {
|
||||
errDetails := a.HTTPError()
|
||||
return echo.NewHTTPError(errDetails.Code, errDetails)
|
||||
}
|
||||
models.Log.Error(err.Error())
|
||||
return echo.NewHTTPError(http.StatusInternalServerError)
|
||||
}
|
||||
|
|
|
|||
Reference in a new issue