/** * @test */ public function resultFromErrorEventContainsExceptionMessage() { $error = new ErrorEvent(); $error->setException(new \Exception('message')); $factory = new ConsoleResultFactory(); $result = $factory->fromEvent($error); $this->assertEquals('message', $result->getErrorMessage()); }
/** * @param \SolrInputDocument $doc */ private function addDocumentToIndex($doc) { try { $updateResponse = $this->solrClient->addDocument($doc); $this->solrClient->commit(); } catch (\Exception $e) { $errorEvent = new ErrorEvent(null, null, 'add-document'); $errorEvent->setException($e); $this->eventManager->handle(EventManager::ERROR, $errorEvent); } }
/** * @param object $doc * @param MetaInformationInterface $metaInformation * @param Event $event */ private function addDocumentToIndex($doc, MetaInformationInterface $metaInformation, Event $event) { try { $indexName = $metaInformation->getIndex(); $client = new \FS\SolrBundle\Client\Client($this->solrClientCore); $client->update($doc, $indexName); } catch (\Exception $e) { $errorEvent = new ErrorEvent(null, $metaInformation, json_encode($this->solrClientCore->getOptions()), $event); $errorEvent->setException($e); $this->eventManager->dispatch(Events::ERROR, $errorEvent); } }