Merge pull request #3459 from jmcclelland/paypal-express-recur-master
[civicrm-core.git] / CRM / Core / TemporaryErrorScope.php
index 697698ce1a38d47c467f1a4019c98bebba25c737..eaf744a1ac4276541d4f2063a411610266fdb874 100644 (file)
 class CRM_Core_TemporaryErrorScope {
   static $oldFrames;
 
+  /**
+   * @return CRM_Core_TemporaryErrorScope
+   */
   public static function useException() {
+    return self::create(array('CRM_Core_Error', 'exceptionHandler'), 1);
+  }
+
+  /**
+   * @return CRM_Core_TemporaryErrorScope
+   */
+  public static function ignoreException() {
+    return self::create(array('CRM_Core_Error', 'nullHandler'));
+  }
+
+  /**
+   * @param mixed $callback
+   * @param null $modeException
+   *
+   * @return CRM_Core_TemporaryErrorScope
+   */
+  public static function create($callback, $modeException = NULL) {
     $newFrame = array(
       '_PEAR_default_error_mode' => PEAR_ERROR_CALLBACK,
-      '_PEAR_default_error_options' => array('CRM_Core_Error', 'exceptionHandler'),
-      'modeException' => 1,
+      '_PEAR_default_error_options' => $callback,
+      'modeException' => $modeException,
     );
     return new CRM_Core_TemporaryErrorScope($newFrame);
   }
 
+  /**
+   * @param $newFrame
+   */
   public function __construct($newFrame) {
     self::$oldFrames[] = self::getActive();
     self::setActive($newFrame);