existent-path');
} catch (err) {
  process.report.writeReport(err);
}
// Any other code
</code></pre>
<p>If both filename and error object are passed to <code>writeReport()</code> the
error object must be the second parameter.</p>
<pre><code class="language-js">try {
  process.chdir('/non-existent-path');
} catch (err) {
  process.report.writeReport(filename, err);
}
// Any other code
</code></pre>
<p>The content of the diagnostic report can be returned as a JavaScript Object
via an API call from a JavaScri