Skip to content

Commit 2fb181d

Browse files
authored
Merge pull request #199 from itk-dev/feature/190-maestro-notification-exception-handling
#190: Rethrow exception to ensure failed job status in Maestro notifi…
2 parents 159453b + 620d198 commit 2fb181d

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ before starting to add changes. Use example [placed in the end of the page](#exa
1111

1212
## [Unreleased]
1313

14+
- [PR-191](https://github.com/OS2Forms/os2forms/pull/191)
15+
Re-throws exception to ensure failed status during Maestro notification job.
1416
- [PR-202](https://github.com/OS2Forms/os2forms/pull/202)
1517
- Removed non-digits from recipient id in Maestro digital post notifications.
1618
- [PR-189](https://github.com/OS2Forms/os2forms/pull/189)

modules/os2forms_forloeb/src/MaestroHelper.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,14 @@ public function processJob(Job $job): JobResult {
205205

206206
$submission = $this->webformSubmissionStorage->load($submissionID);
207207

208-
$this->sendNotification($notificationType, $submission, $templateTask, $maestroQueueID);
208+
try {
209+
$this->sendNotification($notificationType, $submission, $templateTask, $maestroQueueID);
210+
}
211+
catch (\Exception $e) {
212+
// Logging is done by the sendNotification method.
213+
// The job should be considered failed.
214+
return JobResult::failure($e->getMessage());
215+
}
209216

210217
return JobResult::success();
211218
}
@@ -261,12 +268,15 @@ private function sendNotification(
261268
}
262269
}
263270
catch (\Exception $exception) {
271+
// Log with context and rethrow exception.
264272
$this->error('Error sending notification: @message', $context + [
265273
'@message' => $exception->getMessage(),
266274
'handler_id' => 'os2forms_forloeb',
267275
'operation' => 'notification failed',
268276
'exception' => $exception,
269277
]);
278+
279+
throw $exception;
270280
}
271281
}
272282

0 commit comments

Comments
 (0)