Discussion:
CURL body on error
r***@charter.net
2014-01-22 15:40:25 UTC
Permalink
Currently I have code that looks like:
$result = curl_exec($this->_ch);
if( $result === false)
{
$info = curl_getinfo($this->_ch);
$errormsg = 'ModifyPresentationProperty error: ' .
curl_error($this->_ch);
throw new \Exception($errormsg);
}
$jsonresult = json_decode($result);
The problem that when there is an error the server puts additional error
information in the body of the response ("odata.error"). How do I access
the data in the body when there is an error? Right now I only get
$result which is false in the event of an error and curl_error only
gives me the error code and a string describing the error code. The
function curl_info seems to return only information about the request.
This is CURL that comes with PHP 5.5.7. Curl reports version 7.30.0

Thank you.
Tsvetan Nikolov
2014-01-23 09:12:24 UTC
Permalink
Have you tried curl_error() function from the php official documentation?
Post by r***@charter.net
$result = curl_exec($this->_ch);
if( $result === false)
{
$info = curl_getinfo($this->_ch);
$errormsg = 'ModifyPresentationProperty error: ' .
curl_error($this->_ch);
throw new \Exception($errormsg);
}
$jsonresult = json_decode($result);
The problem that when there is an error the server puts additional error
information in the body of the response ("odata.error"). How do I access
the data in the body when there is an error? Right now I only get $result
which is false in the event of an error and curl_error only gives me the
error code and a string describing the error code. The function curl_info
seems to return only information about the request.
This is CURL that comes with PHP 5.5.7. Curl reports version 7.30.0
Thank you.
Continue reading on narkive:
Loading...