@@ -49,6 +49,14 @@ func httpGet(url string, jdata interface{}) error {
49
49
return errors.New("Page not found!")
50
50
case r.StatusCode == int(403):
51
51
return errors.New("Access denied!")
52
+ case r.StatusCode == int(500):
53
+ response, err := ioutil.ReadAll(r.Body)
54
+ if err != nil {
55
+ return err
56
+ }
57
+
58
+ return errors.New(string(response))
59
+
52
60
case r.StatusCode != int(200):
53
61
log.Debugf("GET Status '%s' status code %d \n", r.Status, r.StatusCode)
54
62
return errors.New(r.Status)
@@ -84,6 +92,14 @@ func httpDelete(url string) error {
84
92
return nil
85
93
case r.StatusCode == int(403):
86
94
return errors.New("Access denied!")
95
+ case r.StatusCode == int(500):
96
+ response, err := ioutil.ReadAll(r.Body)
97
+ if err != nil {
98
+ return err
99
+ }
100
+
101
+ return errors.New(string(response))
102
+
87
103
case r.StatusCode != int(200):
88
104
log.Debugf("DELETE Status '%s' status code %d \n", r.Status, r.StatusCode)
89
105
return errors.New(r.Status)
@@ -110,6 +126,14 @@ func httpPost(url string, jdata interface{}) error {
110
126
return errors.New("Page not found!")
111
127
case r.StatusCode == int(403):
112
128
return errors.New("Access denied!")
129
+ case r.StatusCode == int(500):
130
+ response, err := ioutil.ReadAll(r.Body)
131
+ if err != nil {
132
+ return err
133
+ }
134
+
135
+ return errors.New(string(response))
136
+
113
137
case r.StatusCode != int(200):
114
138
log.Debugf("POST Status '%s' status code %d \n", r.Status, r.StatusCode)
115
139
return errors.New(r.Status)
@@ -148,7 +172,7 @@ func (c *ContivClient) {{ initialCap .Name }}Post(obj *{{ initialCap .Name }}) e
148
172
// http post the object
149
173
err := httpPost(url, obj)
150
174
if err != nil {
151
- log.Errorf ("Error creating {{ .Name }} %+v. Err: %v", obj, err)
175
+ log.Debugf ("Error creating {{ .Name }} %+v. Err: %v", obj, err)
152
176
return err
153
177
}
154
178
@@ -164,7 +188,7 @@ func (c *ContivClient) {{ initialCap .Name }}List() (*[]*{{ initialCap .Name }},
164
188
var objList []*{{ initialCap .Name }}
165
189
err := httpGet(url, &objList)
166
190
if err != nil {
167
- log.Errorf ("Error getting {{ .Name }}s. Err: %v", err)
191
+ log.Debugf ("Error getting {{ .Name }}s. Err: %v", err)
168
192
return nil, err
169
193
}
170
194
@@ -181,7 +205,7 @@ func (c *ContivClient) {{ initialCap .Name }}Get({{range $index, $element := .Ke
181
205
var obj {{ initialCap .Name }}
182
206
err := httpGet(url, &obj)
183
207
if err != nil {
184
- log.Errorf ("Error getting {{ .Name }} %+v. Err: %v", keyStr, err)
208
+ log.Debugf ("Error getting {{ .Name }} %+v. Err: %v", keyStr, err)
185
209
return nil, err
186
210
}
187
211
@@ -197,7 +221,7 @@ func (c *ContivClient) {{ initialCap .Name }}Delete({{range $index, $element :=
197
221
// http get the object
198
222
err := httpDelete(url)
199
223
if err != nil {
200
- log.Errorf ("Error deleting {{ .Name }} %s. Err: %v", keyStr, err)
224
+ log.Debugf ("Error deleting {{ .Name }} %s. Err: %v", keyStr, err)
201
225
return err
202
226
}
203
227
0 commit comments