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. 13
      src/EventGenerator/EmitEvent.php

13
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.
try {
$user = $this->entityTypeManager->getStorage('user')->load($this->account->id()); $user = $this->entityTypeManager->getStorage('user')->load($this->account->id());
$data = $this->generateData($entity); $data = $this->generateData($entity);
$message = new Message( $message = new Message(
$this->eventGenerator->generateEvent($entity, $user, $data), $this->eventGenerator->generateEvent($entity, $user, $data),
['Authorization' => "Bearer $token"] ['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