From 7922c1d3dd00cb3b403c05fbd591944236458c51 Mon Sep 17 00:00:00 2001 From: Xavier Dutoit Date: Wed, 4 Sep 2013 11:44:49 +0200 Subject: [PATCH] add error_message on curl error+json_decode error --- api/class.api.php | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/api/class.api.php b/api/class.api.php index 06bc404ec5..f6c9f500b4 100644 --- a/api/class.api.php +++ b/api/class.api.php @@ -173,11 +173,22 @@ class civicrm_api3 { if (curl_errno($ch)) { $res = new stdClass; $res->is_error = 1; + $res->error_message = curl_error($ch); + $res->level = "cURL"; $res->error = array('cURL error' => curl_error($ch)); return $res; } curl_close($ch); - return json_decode($result); + $res = json_decode($result); + if (!$res) { + $res = new stdClass; + $res->is_error = 1; + $res->error_message = "not a valid json returned by the server"; + $res->level = "json_decode"; + $res->row_result = $result; + + } + return $res; } else { // Should be discouraged, because the API credentials and data -- 2.25.1