title: Rails multiline debug in byebug or how to rescue in single line
body: <p>Sometimes I need to debug some nasty exception that has its backtrace hidden or truncated, like an <code>ArgumentError</code> without any stack trace. </p>
  
  <p>I am used to debugging with byebug. The problem is that the byebug interpreter is a REPL, so it's not possible to write multiline code. I am trying to figure out how to make an inline rescue and print the backtrace from there, ie <strong>I want an inline, REPL compatible, version of</strong> </p>
  
  <pre><code>begin 
    .... 
  rescue =&gt; e 
    puts e.backtrace.join("\n")
  end
  </code></pre>
  
  <p>I have tried </p>
  
  <pre><code>begin; my_crashing_method.call; rescue Exception =&gt; e; puts e.backtrace; end
  </code></pre>
  
  <p>But that line raises a SyntaxError</p>
  
  <pre><code>*** SyntaxError Exception: (byebug):1: syntax error, unexpected keyword_rescue
  rescue Exception =&gt; e
        ^
  </code></pre>
  
  <p>I'm not sure what I am missing ?</p>
  
  <p>EDIT</p>
  
  <p>The line above works fine on a regular IRB/Rails shell but not from a byebug shell</p>
  
  <p>IRB</p>
  
  <pre><code>begin my_crashing_method.call; rescue Exception =&gt; e; puts e.backtrace end
  </code></pre>
  
  <blockquote>
    <p>Stack Trace shows successfully</p>
  </blockquote>
  
  <p>Byebug</p>
  
  <pre><code>(byebug) begin; my_crashing_method.call; rescue Exception =&gt; e; puts e.backtrace
  *** SyntaxError Exception: (byebug):1: syntax error, unexpected end-of-input
  begin
       ^
  
  nil
  *** NameError Exception: undefined local variable or method `my_crashing_method' for #&lt;StaticPagesController:0x007fae79f61088&gt;
  
  nil
  *** SyntaxError Exception: (byebug):1: syntax error, unexpected keyword_rescue
  rescue Exception =&gt; e
        ^
  
  nil
  *** NameError Exception: undefined local variable or method `e' for #&lt;StaticPagesController:0x007fae79f61088&gt;
  
  nil
  </code></pre>