4
4
"bytes"
5
5
"context"
6
6
"encoding/json"
7
+ "errors"
7
8
"fmt"
8
9
"net/http"
9
10
"net/url"
@@ -166,13 +167,6 @@ func (c *baseClientImpl) ExecuteMultisearch(r *MultiSearchRequest) (*MultiSearch
166
167
167
168
c .logger .Debug ("Received multisearch response" , "code" , res .StatusCode , "status" , res .Status , "content-length" , res .ContentLength )
168
169
169
- if res .StatusCode >= 400 {
170
- jsonResponseBody , _ := json .Marshal (res .Body )
171
- jsonQueryParam , _ := json .Marshal (queryParams )
172
- jsonRequestBody , _ := json .Marshal (r .Requests )
173
- c .logger .Error ("Error on multisearch: statusCode = " + strconv .Itoa (res .StatusCode ) + ", responseBody = " + string (jsonResponseBody ) + ", queryParam = " + string (jsonQueryParam ) + ", requestBody = " + string (jsonRequestBody ))
174
- }
175
-
176
170
start := time .Now ()
177
171
c .logger .Debug ("Decoding multisearch json response" )
178
172
@@ -188,6 +182,16 @@ func (c *baseClientImpl) ExecuteMultisearch(r *MultiSearchRequest) (*MultiSearch
188
182
189
183
msr .Status = res .StatusCode
190
184
185
+ if res .StatusCode >= 400 {
186
+ jsonResponseBody , _ := json .Marshal (res .Body )
187
+ jsonQueryParam , _ := json .Marshal (queryParams )
188
+ jsonRequestBody , _ := json .Marshal (r .Requests )
189
+ err_msg := "Error on multisearch: statusCode = " + strconv .Itoa (res .StatusCode ) + ", responseBody = " + string (jsonResponseBody ) + ", queryParam = " + string (jsonQueryParam ) + ", requestBody = " + string (jsonRequestBody )
190
+ c .logger .Error (err_msg )
191
+
192
+ return & msr , errors .New (err_msg )
193
+ }
194
+
191
195
return & msr , nil
192
196
}
193
197
0 commit comments