From 7a514fb165aefd81bc7a3dc1316d9ad6480211f4 Mon Sep 17 00:00:00 2001 From: Chris Burgess Date: Fri, 31 May 2013 12:59:44 +1200 Subject: [PATCH] Return a CiviCRM-looking error if we hit a cURL error. Handle cURL errors by synthesising a CiviCRM error object. This is API so we can't depend on having CRM_Core_Error::createError() available. --- api/class.api.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/api/class.api.php b/api/class.api.php index f848ec9cf7..65c06459ef 100644 --- a/api/class.api.php +++ b/api/class.api.php @@ -140,6 +140,13 @@ class civicrm_api3 { //execute post $result = curl_exec($ch); + // CiviCRM expects to get back a CiviCRM error object. + if (curl_errno($ch)) { + $res = new stdClass; + $res->is_error = 1; + $res->error = array('cURL error' => curl_error($ch)); + return $res; + } curl_close($ch); return json_decode($result); // not good, all in get when should be in post. -- 2.25.1