<p dir="auto">Consider the following code:</p>
<div class="highlight highlight-source-ts notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="const path = &quot;./404.txt&quot;;
await Deno.readTextFile(path);"><pre class="notranslate"><span class="pl-k">const</span> <span class="pl-s1">path</span> <span class="pl-c1">=</span> <span class="pl-s">"./404.txt"</span><span class="pl-kos">;</span>
<span class="pl-k">await</span> <span class="pl-smi">Deno</span><span class="pl-kos">.</span><span class="pl-en">readTextFile</span><span class="pl-kos">(</span><span class="pl-s1">path</span><span class="pl-kos">)</span><span class="pl-kos">;</span></pre></div>
<p dir="auto">I get the following error when I run the script.</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="error: Uncaught (in promise) NotFound: No such file or directory (os error 2)
const text = await Deno.readTextFile(path);
             ^
    at deno:core/core.js:86:46
    at unwrapOpResult (deno:core/core.js:106:13)
    at async open (deno:runtime/js/40_files.js:46:17)
    at async Object.readTextFile (deno:runtime/js/40_read_file.js:40:18)
    at async file:///Users/sr/deno_issues/io_error.ts:2:14"><pre class="notranslate"><code class="notranslate">error: Uncaught (in promise) NotFound: No such file or directory (os error 2)
const text = await Deno.readTextFile(path);
             ^
    at deno:core/core.js:86:46
    at unwrapOpResult (deno:core/core.js:106:13)
    at async open (deno:runtime/js/40_files.js:46:17)
    at async Object.readTextFile (deno:runtime/js/40_read_file.js:40:18)
    at async file:///Users/sr/deno_issues/io_error.ts:2:14
</code></pre></div>
<p dir="auto">It isn't easy to debug when you've hundreds of files with the above information.</p>
<p dir="auto">One thing I'm not sure about is if we should delegate the responsibility to scripts or if we should include the path in Deno's built-in error itself.</p>
<p dir="auto">I favor including the path in the default error message as most scripts usually won't take the extra effort to display additional information when they encounter the error.</p>
<p dir="auto">Currently the error message of the exception, thrown from the <code class="notranslate">Deno.stat/statSync</code>, when the file is missing, does not include the file name:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="nickolay@frontier:~/workspace/Bryntum/siesta-monorepo/siesta$ deno
Deno 1.9.2
exit using ctrl+d or close()
&gt; Deno.statSync('/home/nickolay/not_existing_file')
Uncaught NotFound: No such file or directory (os error 2)
    at unwrapOpResult (deno:core/core.js:99:13)
    at Object.opSync (deno:core/core.js:113:12)
    at Object.statSync (deno:runtime/js/30_fs.js:224:22)
    at &lt;anonymous&gt;:2:6
&gt; "><pre class="notranslate"><code class="notranslate">nickolay@frontier:~/workspace/Bryntum/siesta-monorepo/siesta$ deno
Deno 1.9.2
exit using ctrl+d or close()
&gt; Deno.statSync('/home/nickolay/not_existing_file')
Uncaught NotFound: No such file or directory (os error 2)
    at unwrapOpResult (deno:core/core.js:99:13)
    at Object.opSync (deno:core/core.js:113:12)
    at Object.statSync (deno:runtime/js/30_fs.js:224:22)
    at &lt;anonymous&gt;:2:6
&gt; 
</code></pre></div>
<p dir="auto">Is this intentional with some rationale behind, or just an oversight? From usability perspective the filename should be included in the message of course.</p>