Loading ...
Sorry, an error occurred while loading the content.

Problem with --remote-expr and error checking

Expand Messages
  • Андрей Радев
    While trying to evaluate commands on a remote server and get their output, I ve ran into a problem with error checking -- it seems like with remote-expr
    Message 1 of 6 , Mar 9, 2013
    • 0 Attachment
      While trying to evaluate commands on a remote server and get their
      output, I've ran into a problem with error checking -- it seems like
      with remote-expr there's no error-checking at all.

      The simplest example I can think of is this (gist:
      https://gist.github.com/AndrewRadev/5123706):

      function! Test()
      try
      exe "frobble"
      return 1
      catch
      return 2
      endtry
      endfunction

      If I open a Vim with `vim --servername FOO` and :source this file,
      executing `:echo Test()` results in 2, since there is no "frobble"
      command. However, if I then try `vim --servername FOO --remote-expr
      'Test()'`, I get 1. I tried avoiding try/catch and using `v:errmsg`
      instead, but that variable is also not set to the last error if the
      function is invoked with `--remote-expr`.

      For now, I'm working around this issue by using `--remote-send` to
      type in a function, which evaluates the expression and sticks the
      result in a global variable, and then `--remote-expr` to get the value
      of the global variable. I'd really like to avoid this, though, since
      it causes some other problems. Is this a known limitation or a bug? Is
      there any other way for me to get error messages?

      --
      --
      You received this message from the "vim_dev" maillist.
      Do not top-post! Type your reply below the text you are replying to.
      For more information, visit http://www.vim.org/maillist.php

      ---
      You received this message because you are subscribed to the Google Groups "vim_dev" group.
      To unsubscribe from this group and stop receiving emails from it, send an email to vim_dev+unsubscribe@....
      For more options, visit https://groups.google.com/groups/opt_out.
    • Christian Brabandt
      Hi Андрей! ... This happens, because error handling is explicitly disabled at eval_client_expr_to_string() in main.c I think, we can at least enable
      Message 2 of 6 , Mar 9, 2013
      • 0 Attachment
        Hi Андрей!

        On Sa, 09 Mär 2013, Андрей Радев wrote:

        > While trying to evaluate commands on a remote server and get their
        > output, I've ran into a problem with error checking -- it seems like
        > with remote-expr there's no error-checking at all.
        >
        > The simplest example I can think of is this (gist:
        > https://gist.github.com/AndrewRadev/5123706):
        >
        > function! Test()
        > try
        > exe "frobble"
        > return 1
        > catch
        > return 2
        > endtry
        > endfunction
        >
        > If I open a Vim with `vim --servername FOO` and :source this file,
        > executing `:echo Test()` results in 2, since there is no "frobble"
        > command. However, if I then try `vim --servername FOO --remote-expr
        > 'Test()'`, I get 1. I tried avoiding try/catch and using `v:errmsg`
        > instead, but that variable is also not set to the last error if the
        > function is invoked with `--remote-expr`.

        This happens, because error handling is explicitly disabled at
        eval_client_expr_to_string() in main.c

        I think, we can at least enable exception handling by this
        patch:

        --- a/src/message.c
        +++ b/src/message.c
        @@ -587,7 +587,13 @@

        /* Skip this if not giving error messages at the moment. */
        if (emsg_not_now())
        + {
        +#ifdef FEAT_EVAL
        + /* make sure, exceptions are thrown and handled nevertheless */
        + cause_errthrow(s, emsg_severe, &ignore);
        +#endif
        return TRUE;
        + }

        called_emsg = TRUE;
        ex_exitval = 1;


        regards,
        Christian
        --

        --
        --
        You received this message from the "vim_dev" maillist.
        Do not top-post! Type your reply below the text you are replying to.
        For more information, visit http://www.vim.org/maillist.php

        ---
        You received this message because you are subscribed to the Google Groups "vim_dev" group.
        To unsubscribe from this group and stop receiving emails from it, send an email to vim_dev+unsubscribe@....
        For more options, visit https://groups.google.com/groups/opt_out.
      • Bram Moolenaar
        ... Thanks Christian! -- hundred-and-one symptoms of being an internet addict: 36. You miss more than five meals a week downloading the latest games from
        Message 3 of 6 , Mar 9, 2013
        • 0 Attachment
          Christian Brabandt wrote:

          > On Sa, 09 Mär 2013, Андрей Радев wrote:
          >
          > > While trying to evaluate commands on a remote server and get their
          > > output, I've ran into a problem with error checking -- it seems like
          > > with remote-expr there's no error-checking at all.
          > >
          > > The simplest example I can think of is this (gist:
          > > https://gist.github.com/AndrewRadev/5123706):
          > >
          > > function! Test()
          > > try
          > > exe "frobble"
          > > return 1
          > > catch
          > > return 2
          > > endtry
          > > endfunction
          > >
          > > If I open a Vim with `vim --servername FOO` and :source this file,
          > > executing `:echo Test()` results in 2, since there is no "frobble"
          > > command. However, if I then try `vim --servername FOO --remote-expr
          > > 'Test()'`, I get 1. I tried avoiding try/catch and using `v:errmsg`
          > > instead, but that variable is also not set to the last error if the
          > > function is invoked with `--remote-expr`.
          >
          > This happens, because error handling is explicitly disabled at
          > eval_client_expr_to_string() in main.c
          >
          > I think, we can at least enable exception handling by this
          > patch:

          Thanks Christian!


          --
          hundred-and-one symptoms of being an internet addict:
          36. You miss more than five meals a week downloading the latest games from
          Apogee.

          /// Bram Moolenaar -- Bram@... -- http://www.Moolenaar.net \\\
          /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
          \\\ an exciting new programming language -- http://www.Zimbu.org ///
          \\\ help me help AIDS victims -- http://ICCF-Holland.org ///

          --
          --
          You received this message from the "vim_dev" maillist.
          Do not top-post! Type your reply below the text you are replying to.
          For more information, visit http://www.vim.org/maillist.php

          ---
          You received this message because you are subscribed to the Google Groups "vim_dev" group.
          To unsubscribe from this group and stop receiving emails from it, send an email to vim_dev+unsubscribe@....
          For more options, visit https://groups.google.com/groups/opt_out.
        • Andrew
          Hey, Christian, The patch seems to fix the issue, thanks a lot! I ll look out for the patch release :). Regards, Andrew. -- -- You received this message from
          Message 4 of 6 , Mar 10, 2013
          • 0 Attachment
            Hey, Christian,

            The patch seems to fix the issue, thanks a lot! I'll look out for the patch release :).

            Regards,
            Andrew.

            --
            --
            You received this message from the "vim_dev" maillist.
            Do not top-post! Type your reply below the text you are replying to.
            For more information, visit http://www.vim.org/maillist.php

            ---
            You received this message because you are subscribed to the Google Groups "vim_dev" group.
            To unsubscribe from this group and stop receiving emails from it, send an email to vim_dev+unsubscribe@....
            For more options, visit https://groups.google.com/groups/opt_out.
          • Bram Moolenaar
            ... Hmm, that looks tricky. Maybe it works now, but if emsg_off is set in some other situation it may unexpectedly still throw exceptions. Let s try something
            Message 5 of 6 , Mar 13, 2013
            • 0 Attachment
              Christian Brabandt wrote:

              > Hi Андрей!
              >
              > On Sa, 09 Mär 2013, Андрей Радев wrote:
              >
              > > While trying to evaluate commands on a remote server and get their
              > > output, I've ran into a problem with error checking -- it seems like
              > > with remote-expr there's no error-checking at all.
              > >
              > > The simplest example I can think of is this (gist:
              > > https://gist.github.com/AndrewRadev/5123706):
              > >
              > > function! Test()
              > > try
              > > exe "frobble"
              > > return 1
              > > catch
              > > return 2
              > > endtry
              > > endfunction
              > >
              > > If I open a Vim with `vim --servername FOO` and :source this file,
              > > executing `:echo Test()` results in 2, since there is no "frobble"
              > > command. However, if I then try `vim --servername FOO --remote-expr
              > > 'Test()'`, I get 1. I tried avoiding try/catch and using `v:errmsg`
              > > instead, but that variable is also not set to the last error if the
              > > function is invoked with `--remote-expr`.
              >
              > This happens, because error handling is explicitly disabled at
              > eval_client_expr_to_string() in main.c
              >
              > I think, we can at least enable exception handling by this
              > patch:

              Hmm, that looks tricky. Maybe it works now, but if emsg_off is set in
              some other situation it may unexpectedly still throw exceptions.

              Let's try something else: set emsg_silent instead of emsg_off. I'll
              send out a patch with that solution. Please try it out.


              --
              hundred-and-one symptoms of being an internet addict:
              40. You tell the cab driver you live at
              http://123.elm.street/house/bluetrim.html
              41. You actually try that 123.elm.street address.

              /// Bram Moolenaar -- Bram@... -- http://www.Moolenaar.net \\\
              /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
              \\\ an exciting new programming language -- http://www.Zimbu.org ///
              \\\ help me help AIDS victims -- http://ICCF-Holland.org ///

              --
              --
              You received this message from the "vim_dev" maillist.
              Do not top-post! Type your reply below the text you are replying to.
              For more information, visit http://www.vim.org/maillist.php

              ---
              You received this message because you are subscribed to the Google Groups "vim_dev" group.
              To unsubscribe from this group and stop receiving emails from it, send an email to vim_dev+unsubscribe@....
              For more options, visit https://groups.google.com/groups/opt_out.
            • Andrew
              Hey, Bram, ... Just compiled Vim patchlevel 861 and the problem seems to be resolved. Thanks a lot :). Regards, Andrew. -- -- You received this message from
              Message 6 of 6 , Mar 14, 2013
              • 0 Attachment
                Hey, Bram,

                > Let's try something else: set emsg_silent instead of emsg_off. I'll
                > send out a patch with that solution. Please try it out.

                Just compiled Vim patchlevel 861 and the problem seems to be resolved. Thanks a lot :).

                Regards,
                Andrew.

                --
                --
                You received this message from the "vim_dev" maillist.
                Do not top-post! Type your reply below the text you are replying to.
                For more information, visit http://www.vim.org/maillist.php

                ---
                You received this message because you are subscribed to the Google Groups "vim_dev" group.
                To unsubscribe from this group and stop receiving emails from it, send an email to vim_dev+unsubscribe@....
                For more options, visit https://groups.google.com/groups/opt_out.
              Your message has been successfully submitted and would be delivered to recipients shortly.