weldr: Improve the error message from sourceNewHandler

This commit is contained in:
Brian C. Lane 2020-03-19 15:56:01 -07:00 committed by Tom Gundersen
parent a87c0ee44d
commit 222d09499c
2 changed files with 14 additions and 4 deletions

View file

@ -354,6 +354,15 @@ func (api *API) sourceNewHandler(writer http.ResponseWriter, request *http.Reque
return
}
if request.ContentLength == 0 {
errors := responseError{
ID: "ProjectsError",
Msg: "Missing source",
}
statusResponseError(writer, http.StatusBadRequest, errors)
return
}
var source SourceConfigV0
var err error
if contentType[0] == "application/json" {
@ -366,9 +375,8 @@ func (api *API) sourceNewHandler(writer http.ResponseWriter, request *http.Reque
if err != nil {
errors := responseError{
Code: http.StatusBadRequest,
ID: "HTTPError",
Msg: "Bad Request",
ID: "ProjectsError",
Msg: "Problem parsing POST body: " + err.Error(),
}
statusResponseError(writer, http.StatusBadRequest, errors)
return