Open rbro opened 8 years ago
Sure thing, I'll take a look. I've not got access to an SSRS server right now, I don't suppose you could confirm what the body is (e.g. plain text/html/blank) when it returns a 404 or 503? On 15 Dec 2015 11:03 pm, "rbro" notifications@github.com wrote:
First, thanks for a great library I ran into an issue today where my SSRS server was returning a 503 http error code When that happened, php-ssrs threw an exception "String could not be parsed as XML", but didn't include any detail such as the http response code or the raw response from the server
Looking at the callCurl() method in NTLMphp, it looks like the code is always expecting a xml response when the http code is between 300 and 600, but in my case today, a 503 error was thrown without valid xml Similarily, a 404 could be thrown without valid xml
Could the error handling be updated to send the http code and raw response for cases like this?
Thanks for your help
— Reply to this email directly or view it on GitHub https://github.com/ChartBlocks/php-ssrs/issues/21.
Thanks, is it possible to have it throw the http code and raw response for any non-xml response? For example, if you set it to a non-SSRS invalid url such as http://localhost/test123.php. It would just help for debugging to have more detail rather than just "String could not be parsed as XML".
I changed it for this
`
$httpCode = curl_getinfo($handle, CURLINFO_HTTP_CODE);
if ($httpCode !== 200) {
$this->throwExceptionFromCode($httpCode, $response);
}
curl_close($handle);
$this->_lastResponse = (string) $response;
return $response;
}
private function throwExceptionFromCode($code, $response)
{
switch(true){
case $code == 401:
throw new Exception('SSRS::Unauthorized access');
break;
case $code == 503:
throw new Exception('SSRS::Service Unavailable: ' . $response);
break;
case $code > 299 && $code < 601:
throw ServerException::fromResponse($response);
break;
default:
throw new Exception('HTTP error: ' . $code . ' ' . $response, $code, $response);
break;
}
}`
Maybe something like that can be included? Where also other responses can be added?
First, thanks for a great library. I ran into an issue today where my SSRS server was returning a 503 http error code. When that happened, php-ssrs threw an exception "String could not be parsed as XML", but didn't include any detail such as the http response code or the raw response from the server.
Looking at the callCurl() method in NTLM.php, it looks like the code is always expecting a xml response when the http code is between 300 and 600, but in my case today, a 503 error was thrown without valid xml. Similarily, a 404 could be thrown without valid xml.
Could the error handling be updated to send the http code and raw response for cases like this?
Thanks for your help.