How to debug chained API calls
You can use try/catch and the CiviCRM_API3_Exception class to get more information. It would be something like this:

try{
  $result = civicrm_api3('contact', 'get', $params);
}
catch (CiviCRM_API3_Exception $e) {
  // handle error here
  $errorMessage = $e-&gt;getMessage();
  $errorCode = $e-&gt;getErrorCode();
  $errorData = $e-&gt;getExtraParams();
  return array('error' =&gt; $errorMessage, 'error_code' =&gt; $errorCode, 'error_data' =&gt; $errorData);
}


The getExtraParams method should give you what you are looking for.