From 909daf572c3df19b1f3685d9991b249bbdb3fa76 Mon Sep 17 00:00:00 2001 From: gonzalo Date: Thu, 10 Oct 2024 14:32:49 -0300 Subject: [PATCH] closes #53 --- CHANGELOG.md | 8 ++++++++ composer.json | 2 +- src/Mailchimp.php | 3 ++- src/Mailchimp/Error.php | 10 +++++++++- 4 files changed, 20 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 60120f1..0d35f91 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,13 @@ # Change Log +## [3.0.39](https://github.com/ebizmarts/mailchimp-lib/tree/3.0.39) (2024-10-10) + +[Full Changelog](https://github.com/ebizmarts/mailchimp-lib/compare/3.0.38...3.0.39) + +**Implemented enhancements:** + +- Add the instance value to the log [\#53](https://github.com/ebizmarts/mailchimp-lib/issues/53) + ## [3.0.38](https://github.com/ebizmarts/mailchimp-lib/tree/3.0.38) (2024-02-20) [Full Changelog](https://github.com/ebizmarts/mailchimp-lib/compare/3.0.37...3.0.38) diff --git a/composer.json b/composer.json index 1e59303..7724aa4 100644 --- a/composer.json +++ b/composer.json @@ -1,7 +1,7 @@ { "name": "ebizmarts/mailchimp-lib", "type": "library", - "version": "3.0.38", + "version": "3.0.39", "description": "API client library for the MailChimp", "keywords": ["email", "api","mailchimp"], "homepage": "https://github.com/ebizmarts/mailchimp-lib", diff --git a/src/Mailchimp.php b/src/Mailchimp.php index 8949ed1..5de1a47 100644 --- a/src/Mailchimp.php +++ b/src/Mailchimp.php @@ -260,7 +260,8 @@ public function call($url,$params,$method=Mailchimp::GET) $detail = array_key_exists('detail', $result) ? $result['detail'] : ''; $errors = array_key_exists('errors', $result) ? $result['errors'] : null; $title = array_key_exists('title', $result) ? $result['title'] : ''; - throw new Mailchimp_Error($this->_root . $url, $method, $params, $title, $detail, $errors); + $instance = array_key_exists('title', $result) ? $result['instance'] : null; + throw new Mailchimp_Error($this->_root . $url, $method, $params, $title, $detail, $errors, $instance); } else { throw new Mailchimp_Error($this->_root . $url, $method, $params, $result); } diff --git a/src/Mailchimp/Error.php b/src/Mailchimp/Error.php index a2cea7a..c7ff9d8 100644 --- a/src/Mailchimp/Error.php +++ b/src/Mailchimp/Error.php @@ -32,12 +32,16 @@ class Mailchimp_Error extends Exception * @var array */ protected $errors; + /** + * @var string + */ + protected $instance; /** * @var string */ protected $params; - public function __construct($url,$method='',$params='',$title='',$detail='',$errors=null) + public function __construct($url,$method='',$params='',$title='',$detail='',$errors=null, $instance = null) { $titleComplete = $title . " for Api Call: " . $url; parent::__construct($titleComplete . " - " . $detail); @@ -47,6 +51,7 @@ public function __construct($url,$method='',$params='',$title='',$detail='',$err $this->method = $method; $this->errors = $errors; $this->params = $params; + $this->instance = $instance; } public function getFriendlyMessage() { @@ -73,6 +78,9 @@ public function getFriendlyMessage() $lineParams = $this->params; } $friendlyMessage .= $lineParams; + if ($this->instance) { + $friendlyMessage .= "\n\tInstance: [".$this->instance."]\n"; + } return $friendlyMessage; } public function getUrl()