3 namespace Doctrine\CouchDB\HTTP
;
6 * Base exception class for package Doctrine\ODM\CouchDB\HTTP
8 * @license http://www.opensource.org/licenses/mit-license.php MIT
9 * @link www.doctrine-project.com
11 * @author Kore Nordmann <kore@arbitracker.org>
13 class HTTPException
extends \Doctrine\CouchDB\CouchDBException
17 * @param integer $port
18 * @param string $errstr
19 * @param integer $errno
20 * @return \Doctrine\CouchDB\HTTP\HTTPException
22 public static function connectionFailure( $ip, $port, $errstr, $errno )
24 return new self( sprintf(
25 "Could not connect to server at %s:%d: '%d: %s'",
35 * @param integer $port
36 * @param string $errstr
37 * @param integer $errno
38 * @return \Doctrine\CouchDB\HTTP\HTTPException
40 public static function readFailure( $ip, $port, $errstr, $errno )
42 return new static( sprintf(
43 "Could read from server at %s:%d: '%d: %s'",
53 * @param Response $response
54 * @return \Doctrine\CouchDB\HTTP\HTTPException
56 public static function fromResponse( $path, Response
$response )
58 $response = self
::fixCloudantBulkCustomError($response);
60 if (!isset($response->body
['error'])) {
61 $response->body
['error'] = '';
65 "HTTP Error with status " . $response->status
. " occoured while "
66 . "requesting " . $path . ". Error: " . $response->body
['error']
67 . " " . $response->body
['reason'],
71 private static function fixCloudantBulkCustomError($response)
73 if (isset($response->body
[0]['error']) && isset($response->body
[0]['reason'])) {
74 $response->body
['error'] = $response->body
[0]['error'];
75 $response->body
['reason'] = $response->body
[0]['reason'];