/** * Construct the new exception instance * * @param string $message */ function __construct($message = null) { if (empty($message)) { $message = 'API wrapper is not initialized. Please set proper API URL and key'; } // if parent::__construct($message); }
/** * Construct the new exception instance * * @param string $path */ function __construct($path) { if (empty($message)) { $message = "File '{$path}' is not readable"; } // if parent::__construct($message); }
/** * Construct the new exception instance * * @param integer $code * @param string $server_response * @param string $message */ function __construct($code, $server_response = null, $message = null) { if (empty($message)) { if (isset($this->http_codes[$code])) { $message = 'HTTP error ' . $code . ': ' . $this->http_codes[$code]; } else { $message = 'Unknown HTTP error'; } // if } // if parent::__construct($message); }
/** * Construct the new exception instance * * @param integer $code * @param string $server_response * @param string $message */ function __construct($code, $server_response = null, $message = null) { if ($server_response && substr($server_response, 0, 1) === '{') { $this->server_response = json_decode($server_response, true); } else { $this->server_response = $server_response; } // if if ($message === null) { switch ($code) { case self::BAD_REQUEST: $message = 'Bad Request'; break; case self::UNAUTHORIZED: $message = 'Unauthorized'; break; case self::FORBIDDEN: $message = 'Forbidden'; break; case self::NOT_FOUND: $message = 'Not Found'; break; case self::INVALID_PROPERTIES: $message = 'Invalid Properties'; break; case self::CONFLICT: $message = 'Conflict'; break; case self::OPERATION_FAILED: $message = 'Operation failed'; break; case self::UNAVAILABLE: $message = 'Unavailable'; break; default: $message = 'Unknown HTTP error'; } // switch if (is_array($this->server_response)) { $message .= '. Error (' . $this->server_response['type'] . '): ' . $this->server_response['message']; } else { $message .= '. Error: ' . $this->server_response; } // if } // if parent::__construct($message); }