Permalink
Browse files

Improve error checking

  • Loading branch information...
tbar0970
tbar0970 committed Oct 2, 2017
1 parent d8b5df1 commit 194dfe5c66bebe6d60f335b46acbed1f05bf7c9a
Showing with 3 additions and 3 deletions.
  1. +3 −3 scripts/mailchimp_sync.php
@@ -53,7 +53,7 @@
// Check for / look for a list ID
if (empty($list_id)) {
$lists = $mc->get('lists');
if ($lists == FALSE) {
if (($lists == FALSE) || !$mc->success()) {
trigger_error("Mailchimp API Error calling lists(): ".$mc->getLastError(), E_USER_ERROR);
}
switch (count($lists['lists'])) {
@@ -76,7 +76,7 @@
// Check that the list has the necessary merge vars
$vars = array();
$vars_res = $mc->get('lists/'.$list_id.'/merge-fields');
if (!$vars_res) {
if (!$vars_res || !$mc->success()) {
trigger_error("Mailchimp API Error calling lists/merge-fields: ".$mc->getLastError(), E_USER_ERROR);
}
@@ -118,7 +118,7 @@
// Get the existing members of the mailchimp list
$members_res = $mc->get('lists/'.$list_id.'/members', Array('count' => 10000), 60);
if (FALSE === $members_res) {
if ((FALSE === $members_res) || !$mc->success()) {
trigger_error("Mailchimp API Error fetching list members: ".$mc->getLastError(), E_USER_ERROR);
}
$mc_members = Array();

0 comments on commit 194dfe5

Please sign in to comment.