Example #1
0
 public function __construct(ApiResponse $apiResponse = null, Exception $previous = null)
 {
     $this->_apiResponse = $apiResponse;
     $message = $previous ? $previous->getMessage() : 'Unknown error';
     $status = $previous ? $previous->getCode() : 0;
     if ($apiResponse) {
         if ($error = $apiResponse->error()) {
             $message = $error;
         }
         if ($apiResponse->response() && ($statusCode = $apiResponse->response()->getStatusCode())) {
             $status = $statusCode;
         }
     }
     parent::__construct($message, $status, $previous);
 }
 /**
  * @expectedException \Exception
  * @expectedExceptionMessage JSON Error: Result is empty after parsing
  */
 public function testGetJsonWithEmptyJSON()
 {
     $r = new ApiResponse(null, "content-type: application/json\n\nnull", 200);
     $r->json();
 }