-
-
Notifications
You must be signed in to change notification settings - Fork 812
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
log error message instead of throwing exception #16880
Conversation
(Standard links)
|
Civi/Token/TokenCompatSubscriber.php
Outdated
@@ -63,7 +63,8 @@ public function onEvaluate(TokenValueEvent $e) { | |||
$contact = reset($contact); | |||
if (!$contact || is_a($contact, 'CRM_Core_Error')) { | |||
// FIXME: Need to differentiate errors which kill the batch vs the individual row. | |||
throw new TokenException("Failed to generate token data. Invalid contact ID: " . $row->context['contactId']); | |||
CRM_Core_Error::debug_log_message("Failed to generate token data. Invalid contact ID: " . $row->context['contactId']); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@yashodha Please use \Civi::log()->debug()
@bhahumanists @aydun @eileenmcnaughton You may all have views on this - as this may be contributing to a bad token killing the scheduled reminder job. As we're running a foreach loop throwing an exception will kill the entire batch instead of just the one that failed. |
+1 logging rather aborting seems more reasonable here. |
Thanks @yashodha |
I can see the rationale here - but is there also a risk that people could silently be getting weird emails with missing text due to tokens being skipped? |
Overview
log error message instead of throwing exception
Before
can cause the scheduled job to fail if the token data for a contact is not generated properly.
After
log the error and carry on for the rest of the contacts.