/** * Returns the last occurred error. * * @return string - Last occurred error */ public function getLastError() { $result = ''; if (is_a($this->_lastError, 'Solarium\\Exception\\HttpException')) { if ($this->_lastError->getBody()) { $data = json_decode($this->_lastError->getBody(), true); if (!empty($data['error']['msg'])) { $result = $data['error']['msg']; } } } if (empty($result) && is_a($this->_lastError, 'Exception')) { $result = $this->_lastError->getMessage(); } if (empty($result) && is_string($this->_lastError)) { $result = $this->_lastError; } if (!empty($result) && preg_match('#<pre>(.+)</pre>#', $result, $matches)) { $result = trim($matches[1]); } return strval($result); }