Commit 0e2d52e3 authored by Daniel Harms's avatar Daniel Harms Committed by Trevor Conn

Edinburgh patch to fix issue #1731 (error handling in core-data POST event/) (#1733)

* Fixes error handling in core-data event/ POST rte

Error from a call to `addNewEvent()` was being ignored in the
handler, causing failures to add Events to be swallowed and
200 OKs to be returned to clients.  This change adds error
handling for the route in accordance with the RAML file at
https://github.com/edgexfoundry/edgex-go/blob/master/api/raml/core-data.raml

* Update version numbers for Edinburgh patch release
Signed-off-by: default avatarDaniel Harms <jdharms@gmail.com>
parent de3250e7
......@@ -215,6 +215,20 @@ func eventHandler(w http.ResponseWriter, r *http.Request) {
return
}
newId, err := addNewEvent(evt, ctx)
if err != nil {
switch e := err.(type) {
case *errors.ErrValueDescriptorNotFound:
http.Error(w, err.Error(), http.StatusNotFound)
case *errors.ErrValueDescriptorInvalid:
http.Error(w, err.Error(), http.StatusBadRequest)
case *types.ErrServiceClient:
http.Error(w, e.Error(), e.StatusCode)
default:
http.Error(w, err.Error(), http.StatusInternalServerError)
}
LoggingClient.Error(err.Error())
return
}
w.WriteHeader(http.StatusOK)
w.Write([]byte(newId))
......
......@@ -9,4 +9,4 @@
package edgex
// Global version for edgex-go
var Version string = "1.0.1"
var Version string = "1.0.2"
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment