-
Notifications
You must be signed in to change notification settings - Fork 22
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
fix: allow for context-specific reader-facing error messsages #1754
base: release
Are you sure you want to change the base?
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## release #1754 +/- ##
=============================================
+ Coverage 23.29% 23.35% +0.05%
- Complexity 2710 2714 +4
=============================================
Files 49 49
Lines 10754 10778 +24
=============================================
+ Hits 2505 2517 +12
- Misses 8249 8261 +12 ☔ View full report in Codecov by Sentry. |
@@ -1206,7 +1206,7 @@ public function add_contact( $contact, $list_id = false ) { | |||
// Log the error with any details returned from the API. | |||
do_action( | |||
'newspack_log', | |||
'newspack_constant_contact_add_contact_failed', | |||
'newspack_' . $this->service . '_api_error', |
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.
this logging repeats in every esp. Is it possible to move this up in the abstraction and automatically do it for all of them?
Also, wdyt of adding all errors into the same bucket and add the provider as a piece of data in the params. It's what we do with all the other logs
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.
4acbef7 moves the reader-facing error handling and logging to the higher-level Newspack_Newsletters_Contacts::upsert()
. It simplifies things a bit by repurposing the existing log with the newspack_esp_sync_upsert_contact
error code to log the error message from the ESP's API instead of the reader-facing error message, so there's now no longer a separate log for each. There's probably no reason to log the reader-facing error message for debugging purposes.
The testing instructions remain the same, but you can also verify that the logged output shows the original error message from the API instead of the reader-facing error message:

All Submissions:
Changes proposed in this Pull Request:
Builds on filters added in #1745 by allowing reader-facing error messages to be altered depending on the context of the original error thrown by the ESP's API.
This PR adds a special error message for the Mailchimp error that occurs when a contact attempts to resubscribe to a list they've previously unsubscribed from. In all other cases, the error shown will be a generic error:
Sorry, an error has occurred. Please try again later or contact us for support.
Also standardizes the error code used across all ESP's when
add_contact
results in an error to:newspack_{esp}_api_error
How to test the changes in this Pull Request:
set up a contact for the compliance state
validate()
method:Other information: