title: Begin Rescue not catching error
body: <p>I'm using some ruby code wrapped in a begin - rescue block but somehow it manages to still crash. </p>
  
  <p>the block of code looks like this:</p>
  
  <pre><code># Retrieve messages from server
  def get_messages
    @connection.select('INBOX')
    @connection.uid_search(['ALL']).each do |uid|
      msg = @connection.uid_fetch(uid,'RFC822').first.attr['RFC822']
      begin
        process_message(msg)
        add_to_processed_folder(uid) if @processed_folder
      rescue
         handle_bogus_message(msg)
      end
      # Mark message as deleted 
      @connection.uid_store(uid, "+FLAGS", [:Seen, :Deleted])
    end
  end
  </code></pre>
  
  <p>Given this code i would assume that if <strong>process_message</strong> or <strong>add_to_processed_folder</strong> could not execute then rescue would kick in and call <strong>handle_bogus_message</strong>. That being said I'm running this code in a production environment and  sometimes when i "get" an email message (this is run from a rake task) it dies with a <strong>SyntaxError</strong>. </p>
  
  <p>For a look at the error message check out <a href="http://pastie.org/1028479" rel="noreferrer">http://pastie.org/1028479</a>  and not that <strong>process_message</strong> that it is referring to is the same <strong>process_message</strong> above. Is there any reason why <strong>begin</strong> - <strong>rescue</strong> won't catch this exception? </p>