Deployment\SshServer::protect PHP Method

protect() private method

private protect ( callable $func, $args = [] )
$func callable
    private function protect(callable $func, $args = [])
    {
        set_error_handler(function ($severity, $message) {
            if (ini_get('html_errors')) {
                $message = html_entity_decode(strip_tags($message));
            }
            if (preg_match('#^\\w+\\(\\):\\s*(.+)#', $message, $m)) {
                $message = $m[1];
            }
            throw new SshException($message);
        });
        try {
            $res = call_user_func_array($func, $args);
            restore_error_handler();
        } catch (\Exception $e) {
            restore_error_handler();
            throw $e;
        }
        if ($res === FALSE) {
            throw new SshException(is_string($func) ? "{$func} failures." : NULL);
        }
        return $res;
    }