/** * Removes the active mask from the called class. * @return void */ public static function unmask() { ErrorHandler::removeMask(); }
/** * Captures and masks an exception inside an anonymous closure's code. * This is an equivalent of a try/catch block, but it can catch Fatal * and Php errors. * @param string $message Error message. * @param int $code Error code. * @param closure $closure Closure function containing code to execute. * @param array $params Parameters passed to the function as the first parameter. * @return mixed Returned value from the closure function. */ public static function capture($message = null, $code = 0, $closure, $params = []) { $calledClass = get_called_class(); $exception = new $calledClass($message, $code); ErrorHandler::applyMask($exception); $result = $closure($params); ErrorHandler::removeMask(); return $result; }