@@ -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
@@ -389,7 +399,10 @@ private function sendNotificationDigitalPost(
389399 $ senderLabel = $ subject ;
390400 $ messageLabel = $ subject ;
391401
392- $ recipientLookupResult = $ this ->digitalPostHelper ->lookupRecipient ($ recipient );
402+ // Remove all non-digits from recipient identifier.
403+ $ recipientIdentifier = preg_replace ('/[^\d]+/ ' , '' , $ recipient );
404+
405+ $ recipientLookupResult = $ this ->digitalPostHelper ->lookupRecipient ($ recipientIdentifier );
393406 $ actions = [
394407 (new Action ())
395408 ->setActionCode (SF1601 ::ACTION_SELVBETJENING )
0 commit comments