public function getError()
{
$error = $this->getFullError();
if (!$error) {
return '';
}
if (is_string($error)) {
return $error;
}
$rootError = $error;
if (isset($error['root_cause'][0])) {
$rootError = $error['root_cause'][0];
}
$message = $rootError['reason'];
if (isset($rootError['index'])) {
$message .= ' [index: ' . $rootError['index'] . ']';
}
if (isset($error['reason']) && $rootError['reason'] != $error['reason']) {
$message .= ' [reason: ' . $error['reason'] . ']';
}
return $message;
}
/** * Construct Exception. * * @param \Elastica\Request $request * @param \Elastica\Response $response */ public function __construct(Request $request, Response $response) { $this->_request = $request; $this->_response = $response; parent::__construct($response->getError()); }