weldr: Improve the error message from sourceNewHandler
This commit is contained in:
parent
a87c0ee44d
commit
222d09499c
2 changed files with 14 additions and 4 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue