From e9ecf88e3312e80e37a02c397c9da053f46f3b68 Mon Sep 17 00:00:00 2001 From: Maria Fisher Date: Tue, 27 Apr 2021 09:34:01 -0700 Subject: [PATCH] Issue #94 checking if detail exists before appending to message. --- src/MailchimpAPIException.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/MailchimpAPIException.php b/src/MailchimpAPIException.php index 57f6599..301002e 100644 --- a/src/MailchimpAPIException.php +++ b/src/MailchimpAPIException.php @@ -18,7 +18,10 @@ public function __construct($message = "", $code = 0, Exception $previous = NULL // Construct message from JSON if required. if (substr($message, 0, 1) == '{') { $message_obj = json_decode($message); - $message = $message_obj->status . ': ' . $message_obj->title . ' - ' . $message_obj->detail; + $message = $message_obj->status . ': ' . $message_obj->title; + if (!empty($message_obj->detail)) { + $message .= ' - ' . $message_obj->detail; + } if (!empty($message_obj->errors)) { $message .= ' ' . serialize($message_obj->errors); }