Browse Source

Catching exceptions when generating events to get published on the queue (#93)

pull/756/head
dannylamb 6 years ago committed by Jared Whiklo
parent
commit
d297e9c491
  1. 25
      src/EventGenerator/EmitEvent.php

25
src/EventGenerator/EmitEvent.php

@ -128,12 +128,25 @@ abstract class EmitEvent extends ConfigurableActionBase implements ContainerFact
} }
// Generate event as stomp message. // Generate event as stomp message.
$user = $this->entityTypeManager->getStorage('user')->load($this->account->id()); try {
$data = $this->generateData($entity); $user = $this->entityTypeManager->getStorage('user')->load($this->account->id());
$message = new Message( $data = $this->generateData($entity);
$this->eventGenerator->generateEvent($entity, $user, $data), $message = new Message(
['Authorization' => "Bearer $token"] $this->eventGenerator->generateEvent($entity, $user, $data),
); ['Authorization' => "Bearer $token"]
);
}
catch (\RuntimeException $e) {
// Notify the user the event couldn't be generated and abort.
\Drupal::logger('islandora')->error(
t('Error generating event: @msg', ['@msg' => $e->getMessage()])
);
drupal_set_message(
t('Error generating event: @msg', ['@msg' => $e->getMessage()]),
'error'
);
return;
}
// Send the message. // Send the message.
try { try {

Loading…
Cancel
Save