From 26b7764fd45c15062cb1b21c9389aff919e8c2bd Mon Sep 17 00:00:00 2001 From: Nicolas Le Goff Date: Mon, 7 Jul 2014 18:25:07 +0200 Subject: [PATCH] Add missing classes --- Phlickr/ConnectionException.php | 46 ++++++++++++++++++++++++++++++ Phlickr/MethodFailureException.php | 14 +++++++++ Phlickr/XmlParseException.php | 44 ++++++++++++++++++++++++++++ 3 files changed, 104 insertions(+) create mode 100644 Phlickr/ConnectionException.php create mode 100644 Phlickr/MethodFailureException.php create mode 100644 Phlickr/XmlParseException.php diff --git a/Phlickr/ConnectionException.php b/Phlickr/ConnectionException.php new file mode 100644 index 0000000..10ba382 --- /dev/null +++ b/Phlickr/ConnectionException.php @@ -0,0 +1,46 @@ + +*/ +class Phlickr_ConnectionException extends Phlickr_Exception { +/** +* The URL that was being requested when the problem occured. +* +* @var string +*/ +protected $_url; + +/** +* Constructor +* +* @param string $message Error message +* @param integer $code Error code +* @param string $url URL accessed during failure +*/ +public function __construct($message = null, $code = null, $url = null) { +parent::__construct($message, $code); +$this->_url = (string) $url; +} + +public function __toString() { +$s = "exception '" . __CLASS__ . "' [{$this->code}]: {$this->message}\n"; +if (isset($this->_url)) { +$s .= "URL: {$this->_url}\n"; +} +$s .= "Stack trace:\n" . $this->getTraceAsString(); +return $s; +} + +/** +* Return the URL associated with the connection failure. +* +* @return string +*/ +public function getUrl() { +return $this->_url; +} +} \ No newline at end of file diff --git a/Phlickr/MethodFailureException.php b/Phlickr/MethodFailureException.php new file mode 100644 index 0000000..519ea25 --- /dev/null +++ b/Phlickr/MethodFailureException.php @@ -0,0 +1,14 @@ + + */ +class Phlickr_MethodFailureException extends Phlickr_Exception { +} \ No newline at end of file diff --git a/Phlickr/XmlParseException.php b/Phlickr/XmlParseException.php new file mode 100644 index 0000000..e6d7304 --- /dev/null +++ b/Phlickr/XmlParseException.php @@ -0,0 +1,44 @@ + + */ +class Phlickr_XmlParseException extends Phlickr_Exception { + /** + * + * @var string + */ + protected $_xml; + + /** + * Constructor + * + * @param string $message + * @param string $xml + */ + public function __construct($message = null, $xml = null) { + parent::__construct($message); + $this->_xml = (string) $xml; + } + + public function __toString() { + $s = "exception '" . __CLASS__ . "' {$this->message}\n"; + if (isset($this->_xml)) { + $s .= "XML: '{$this->_xml}'\n"; + } + $s .= "Stack trace:\n" . $this->getTraceAsString(); + return $s; + } + + /** + * Return the un-parseable XML. + * + * @return string + */ + public function getXml() { + return $this->_xml; + } +} \ No newline at end of file