I would suggest to use the Elastica Exception here: https://github.com/ruflin/Elastica/blob/master/lib/Elastica/Exception/InvalidException.php