Correctly handle validation errors vs. errors from the panel during installation

This commit is contained in:
Dane Everitt
2020-04-11 17:55:00 -07:00
parent 13fc464508
commit 7d7766e4cb
3 changed files with 29 additions and 10 deletions

View File

@@ -37,9 +37,14 @@ func postCreateServer(c *gin.Context) {
install, err := installer.New(buf.Bytes())
if err != nil {
TrackedError(err).
SetMessage("Failed to validate the data provided in the request.").
AbortWithStatus(http.StatusUnprocessableEntity, c)
if installer.IsValidationError(err) {
c.AbortWithStatusJSON(http.StatusUnprocessableEntity, gin.H{
"error": "The data provided in the request could not be validated.",
})
return
}
TrackedError(err).AbortWithServerError(c)
return
}