Skip to content

Commit

Permalink
Add missing classes
Browse files Browse the repository at this point in the history
  • Loading branch information
nlegoff committed Jul 7, 2014
1 parent bfd7df7 commit 26b7764
Show file tree
Hide file tree
Showing 3 changed files with 104 additions and 0 deletions.
46 changes: 46 additions & 0 deletions Phlickr/ConnectionException.php
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;
}
}
14 changes: 14 additions & 0 deletions Phlickr/MethodFailureException.php
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 {
}
44 changes: 44 additions & 0 deletions Phlickr/XmlParseException.php
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;
}
}

0 comments on commit 26b7764

Please sign in to comment.