Skip to content
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

Merged
merged 2 commits into from
Mar 25, 2020
Merged

Conversation

yashodha
Copy link
Contributor

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.

@civibot
Copy link

civibot bot commented Mar 23, 2020

(Standard links)

@civibot civibot bot added the master label Mar 23, 2020
@@ -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']);
Copy link
Contributor

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()

@mattwire
Copy link
Contributor

@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.

@aydun
Copy link
Contributor

aydun commented Mar 23, 2020

+1 logging rather aborting seems more reasonable here.

@mattwire
Copy link
Contributor

Thanks @yashodha

@mattwire mattwire merged commit 24267f4 into civicrm:master Mar 25, 2020
@eileenmcnaughton
Copy link
Contributor

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants