/** * Tests the http request response error message. */ public function testHttpRequestResponseErrorMessage() { $response = new NostoHttpResponse(array(), '', 'error'); $this->assertEquals('error', $response->getMessage()); }
/** * Throws a new NostoHttpException exception with info about both the * request and response. * * @param string $message the error message. * @param NostoHttpRequest $request the request object to take additional info from. * @param NostoHttpResponse $response the response object to take additional info from. * @throws NostoHttpException|NostoApiResponseException the exception. */ public static function throwHttpException($message, NostoHttpRequest $request, NostoHttpResponse $response) { $jsonResponse = $response->getJsonResult(); if (isset($jsonResponse->type) && isset($jsonResponse->message)) { if (isset($jsonResponse->message)) { $message .= '. ' . $jsonResponse->message; } throw new NostoApiResponseException($message, $response->getCode(), null, $request, $response); } else { if ($response->getMessage()) { $message .= '. ' . $response->getMessage(); } throw new NostoHttpException($message, $response->getCode(), null, $request, $response); } }