-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
104 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
<?php | ||
|
||
/** | ||
* Exception thrown when there is a problem connecting to the service. | ||
* | ||
* @package Phlickr | ||
* @author Andrew Morton <drewish@katherinehouse.com> | ||
*/ | ||
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; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<?php | ||
|
||
|
||
/** | ||
* Exception (optionally) thrown when an API method call fails. | ||
* | ||
* You can determine if this exception should be thrown by calling | ||
* Phlickr_Request's setExceptionThrownOnFailure() method. | ||
* | ||
* @package Phlickr | ||
* @author Andrew Morton <drewish@katherinehouse.com> | ||
*/ | ||
class Phlickr_MethodFailureException extends Phlickr_Exception { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
<?php | ||
|
||
/** | ||
* Exception thrown when XML cannot be parsed. | ||
* | ||
* @package Phlickr | ||
* @author Andrew Morton <drewish@katherinehouse.com> | ||
*/ | ||
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; | ||
} | ||
} |