public function __construct(puzzle_exception_RequestException $delegate) { parent::__construct($delegate->getMessage(), $delegate->getCode()); $delegateRequest = $delegate->getRequest(); $this->_request = $delegateRequest instanceof tubepress_api_http_message_RequestInterface ? $delegateRequest : new tubepress_http_impl_puzzle_PuzzleBasedRequest($delegateRequest); $delegateResponse = $delegate->getResponse(); if ($delegateResponse !== null) { $this->_response = $delegateResponse instanceof tubepress_api_http_message_ResponseInterface ? $delegateResponse : new tubepress_http_impl_puzzle_PuzzleBasedResponse($delegateResponse); } }
public function testHasRequestAndResponse() { $req = new puzzle_message_Request('GET', '/'); $res = new puzzle_message_Response(200); $e = new puzzle_exception_RequestException('foo', $req, $res); $this->assertSame($req, $e->getRequest()); $this->assertSame($res, $e->getResponse()); $this->assertTrue($e->hasResponse()); $this->assertEquals('foo', $e->getMessage()); }