File tree Expand file tree Collapse file tree 1 file changed +11
-0
lines changed Expand file tree Collapse file tree 1 file changed +11
-0
lines changed Original file line number Diff line number Diff line change @@ -302,6 +302,7 @@ public class Results {
302
302
303
303
if let json = JsonTools . serialiseJson ( input) {
304
304
305
+ // Check for standard Elasticsearch error format
305
306
if let errorMessage = json [ " error " ] as? [ String : Any ] {
306
307
307
308
if let errorItems = errorMessage [ " root_cause " ] as? [ [ String : Any ] ] {
@@ -313,6 +314,16 @@ public class Results {
313
314
}
314
315
}
315
316
317
+ // Return early if there's an error to prevent processing error response fields
318
+ return result
319
+ }
320
+
321
+ // Check for alternative error format with "message" and "ok" fields
322
+ if let message = json [ " message " ] as? String ,
323
+ let ok = json [ " ok " ] as? Bool ,
324
+ ok == false {
325
+ result. error = message
326
+ return result
316
327
}
317
328
318
329
for item in json {
You can’t perform that action at this time.
0 commit comments