+--------------------------------------------------------------------+
| CiviCRM version 4.6 |
+--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2014 |
+ | Copyright CiviCRM LLC (c) 2004-2015 |
+--------------------------------------------------------------------+
| This file is a part of CiviCRM. |
| |
| GNU Affero General Public License or the licensing of CiviCRM, |
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
+--------------------------------------------------------------------+
-*/
+ */
/**
* To ensure that PHP errors or unhandled exceptions are reported in JSON
*
* @code
* $errorContainer = new CRM_Queue_ErrorPolicy();
- * $errorContainer->call(function(){
+ * $errorContainer->call(function() {
* ...include some files, do some work, etc...
* });
* @endcode
$this->active = TRUE;
$this->backup = array();
foreach (array(
- 'display_errors', 'html_errors', 'xmlrpc_errors') as $key) {
+ 'display_errors',
+ 'html_errors',
+ 'xmlrpc_errors',
+ ) as $key) {
$this->backup[$key] = ini_get($key);
ini_set($key, 0);
}
$this->errorScope = NULL;
restore_error_handler();
foreach (array(
- 'display_errors', 'html_errors', 'xmlrpc_errors') as $key) {
+ 'display_errors',
+ 'html_errors',
+ 'xmlrpc_errors',
+ ) as $key) {
ini_set($key, $this->backup[$key]);
}
$this->active = FALSE;
try {
$result = $callable();
}
- catch(Exception$e) {
+ catch (Exception$e) {
$this->reportException($e);
}
$this->deactivate();
}
/**
- * Print a fatal error
+ * Print a fatal error.
*
* @param array $error
* The PHP error (with "type", "message", etc).
}
/**
- * Print an unhandled exception
+ * Print an unhandled exception.
*
* @param Exception $e
* The unhandled exception.
}
CRM_Utils_JSON::output($response);
}
+
}