/** * testServerError method * * @return void */ public function testServerError() { $response = new Att\M2X\HttpResponse($this->_raw('internal_server_error')); $this->assertEquals(500, $response->status()); $this->assertFalse($response->success()); $this->assertFalse($response->clientError()); $this->assertTrue($response->serverError()); $this->assertTrue($response->error()); }
/** * Checks the HttpResponse for errors and throws an exception, if * no errors are encountered, the HttpResponse is returned. * * @param HttpResponse $response * @return HttpResponse * @throws M2XException */ protected function handleResponse(HttpResponse $response) { $this->lastResponse = $response; if ($response->success()) { return $response; } throw new M2XException($response); }
/** * Create the exception from a HttpResponse object * * @param HttpResponse $response */ public function __construct(HttpResponse $response) { $data = $response->json(); $this->response = $response; parent::__construct($data['message'], $response->statusCode); }