title: Take screenshot in catch clause nightmarejs javascript
body: <p>The code below is not working. It fails on nightmare.screenshot('./screenshots/error_inner.png') in the catch clauses. The error messages suggests it's actualy trying to read rather than write the file: error_inner.png</p>
  
  <p>Is there anyone who knows how to get the screenshot when the error occurs. 
  Help is much appricated 
  /Tomas Hesse</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>var Nightmare = require('nightmare'),
    nightmare = Nightmare({
      show: true,
      height: 1080,
      width: 1920
    });
  
  var myVar = 'Non init';
  nightmare
    .goto('http://localhost:8082/myPage1')
    .wait('.recloc')
    .screenshot('./screenshots/tada.png')
    .evaluate(() =&gt; { return document.querySelector('span.myClass').innerHTML;})
   // .end()
    .then((textFound) =&gt; { 
      myVar = textFound;
      console.log('Outer nightmare Sucess:', textFound);
      nightmare.goto('http://localhost:8082/myPage2')
        .wait('#nav &gt; ul.pull-left.navigation.hidden-xs &gt; li:nth-child(3) &gt; a')
        .click('Non existing Element ie Error is thrown')
        .end()
        .then(()=&gt;{
          console.log('Outer nightmare Sucess:', myVar )
      })
      .catch((error) =&gt; {
        nightmare.screenshot('./screenshots/error_inner.png')
          console.error('Inner nightmare failed:', error);
          return nightmare.end();
      })
    })
    .catch((error) =&gt; {
      console.error('Outer nightmare failed:', error);
      nightmare.screenshot('./screenshots/error_outer.png')
      return nightmare.end();
    });</code></pre>
  </div>
  </div>
  </p>