<p dir="auto">I assumed that failing file operations (<code class="notranslate">rm</code>, <code class="notranslate">'mkdir</code>, etc.) return a <code class="notranslate">SystemError</code> when they fail. However, under certain circumstances they return an undocumented <code class="notranslate">UVError</code>. This seems like an unintentional leak of an implementation detail:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="julia&gt; try rm(&quot;a&quot;) catch err info(typeof(err)) end
INFO: Base.UVError
julia&gt; try chmod(&quot;a&quot;, 0) catch err info(typeof(err)) end
INFO: Base.UVError"><pre class="notranslate"><code class="notranslate">julia&gt; try rm("a") catch err info(typeof(err)) end
INFO: Base.UVError
julia&gt; try chmod("a", 0) catch err info(typeof(err)) end
INFO: Base.UVError
</code></pre></div>
<p dir="auto">The printed error messages look fine, but e.g. the error codes have different meanings (<code class="notranslate">SystemError</code> uses <code class="notranslate">errno</code>, <code class="notranslate">UVError</code> uses its own set of constants). Having different exception types makes it difficult to handle these errors programmatically.</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="julia&gt; try
         run(`false`)
       catch err
         dump(err)
       end
ErrorException
  msg: ASCIIString &quot;failed process: Process(`false`, ProcessExited(1)) [1]&quot;

julia&gt; try
         run(`foobar`)
       catch err
         dump(err)
       end
UVError
  prefix: ASCIIString &quot;could not spawn `foobar`&quot;
  code: Int32 -2"><pre class="notranslate"><code class="notranslate">julia&gt; try
         run(`false`)
       catch err
         dump(err)
       end
ErrorException
  msg: ASCIIString "failed process: Process(`false`, ProcessExited(1)) [1]"

julia&gt; try
         run(`foobar`)
       catch err
         dump(err)
       end
UVError
  prefix: ASCIIString "could not spawn `foobar`"
  code: Int32 -2
</code></pre></div>
<p dir="auto">I feel like <code class="notranslate">UVError</code> isn't something that should be escaping the Julia internals. For one thing, I doubt anyone not involved with Julia development knows or wants to know what the <code class="notranslate">UV</code> refers to. Having different exception types thrown from the same method (from the users perspective) feels odd to me, although I think thats a much more debatable point.</p>
<p dir="auto">It bit me recently (I had code like <code class="notranslate">println(fp, err.msg)</code>, which threw an error in the error handler...) and I just saw <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="39363888" data-permission-text="Title is private" data-url="https://github.com/JuliaLang/julia/issues/7822" data-hovercard-type="pull_request" data-hovercard-url="/JuliaLang/julia/pull/7822/hovercard" href="https://github.com/JuliaLang/julia/pull/7822">#7822</a> which made me think of it again.</p>