Better error catching for elasticsearch request