title: Vim: Using an external command and handling errors
body: <p>I am trying to use an external command to handle some formatting over a range of lines in Vim but can't seem to find a way to deal with errors from the external command.</p>
  
  <p>These errors are usually when the shell returns something other than 0 and it prompts Vim to display something along the lines of:</p>
  
  <pre><code>shell returned 1
  </code></pre>
  
  <p>Besides doing that, it replaces the lines I wanted to format with the actual message of the error. This happens as well if I do:</p>
  
  <pre><code>:set equalprg=myformatter\ --format-flag\
  </code></pre>
  
  <p>How can I safely catch an error for an external command and display whatever the error message is?</p>
  
  <p>Note: this is <em>not</em> a question on how to <em>use</em> an external command to format some text in Vim, but rather, how to catch an error and display the message back.</p>