>
<pre><code class="language-js">process.report.writeReport('./foo.json');
</code></pre>
<p>This function takes an optional additional argument <code>err</code> - an <code>Error</code> object
that will be used as the context for the JavaScript stack printed in the report.
When using report to handle errors in a callback or an exception handler, this
allows the report to include the location of the original error as well
as where it was handled.</p>
<pre><code class="language-js">try {
  process.chdir('/non-