[REV] change http status to 400

This commit is contained in:
GLYASAI 2019-05-16 11:10:30 +08:00
parent e64a938e38
commit 048dcd5d65

View File

@ -21,6 +21,7 @@ package controller
import (
"encoding/json"
"fmt"
"github.com/goodrain/rainbond/db/errors"
"io/ioutil"
"net/http"
"net/url"
@ -1099,6 +1100,10 @@ func (t *TenantStruct) AddEnv(w http.ResponseWriter, r *http.Request) {
envD.Name = envM.Name
envD.Scope = envM.Scope
if err := handler.GetServiceManager().EnvAttr("add", &envD); err != nil {
if err == errors.ErrRecordAlreadyExist {
httputil.ReturnError(r, w, 400, fmt.Sprintf("%v", err))
return
}
logrus.Errorf("Add env error, %v", err)
httputil.ReturnError(r, w, 500, fmt.Sprintf("Add env error, %v", err))
return