You are here

public function MailchimpAPIException::__construct in Mailchimp 8

@inheritdoc

File

lib/mailchimp-api-php/src/MailchimpAPIException.php, line 17

Class

MailchimpAPIException
Custom Mailchimp API exception.

Namespace

Mailchimp

Code

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;
    if (!empty($message_obj->errors)) {
      $message .= ' ' . serialize($message_obj->errors);
    }
  }
  parent::__construct($message, $code, $previous);
}