aboutsummaryrefslogtreecommitdiffstats
path: root/src/dcm/api/clusterHandler.go
diff options
context:
space:
mode:
authorRitu Sood <ritu.sood@intel.com>2020-09-25 16:36:24 +0000
committerGerrit Code Review <gerrit@onap.org>2020-09-25 16:36:24 +0000
commit8b5c4236639a46f39cbfe852590f34e64f58a85a (patch)
treea2130c27227dbeffb903888b777ece8afd8f8302 /src/dcm/api/clusterHandler.go
parent6498e883dcbc005b32f86f8a57c96950c359d98e (diff)
parentc585d2b091875dbc9575a960f4f42c1f14ec3366 (diff)
Merge "Enhance error handling and HTTP codes in DCM"
Diffstat (limited to 'src/dcm/api/clusterHandler.go')
-rw-r--r--src/dcm/api/clusterHandler.go10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/dcm/api/clusterHandler.go b/src/dcm/api/clusterHandler.go
index f4a3abdc..d0c1e62c 100644
--- a/src/dcm/api/clusterHandler.go
+++ b/src/dcm/api/clusterHandler.go
@@ -91,6 +91,10 @@ func (h clusterHandler) getHandler(w http.ResponseWriter, r *http.Request) {
} else {
ret, err = h.client.GetCluster(project, logicalCloud, name)
if err != nil {
+ if err.Error() == "Cluster Reference does not exist" {
+ http.Error(w, err.Error(), http.StatusNotFound)
+ return
+ }
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
@@ -131,12 +135,16 @@ func (h clusterHandler) updateHandler(w http.ResponseWriter, r *http.Request) {
ret, err := h.client.UpdateCluster(project, logicalCloud, name, v)
if err != nil {
+ if err.Error() == "Cluster Reference does not exist" {
+ http.Error(w, err.Error(), http.StatusNotFound)
+ return
+ }
http.Error(w, err.Error(),
http.StatusInternalServerError)
return
}
w.Header().Set("Content-Type", "application/json")
- w.WriteHeader(http.StatusCreated)
+ w.WriteHeader(http.StatusOK)
err = json.NewEncoder(w).Encode(ret)
if err != nil {
http.Error(w, err.Error(),