<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<br>
<blockquote type="cite"
cite="mid:026071b30d0ce46a48154847697e754c533d4907.camel@volker-wysk.de">
<blockquote type="cite" style="margin:0 0 0 .8ex; border-left:2px
#729fcf solid;padding-left:1ex">
<blockquote type="cite"
cite="mid:9e86fd24e8505d3644ad14cba311bbf7fbb786f3.camel@volker-wysk.de"
style="margin:0 0 0 .8ex; border-left:2px #729fcf
solid;padding-left:1ex"><br>
<pre>I want to read the contents of a file, using open_input,</pre>
<pre>read_file_as_string, close_input. In case the file doesn't exist, I want to</pre>
<pre>return an empty string. So, in case of an error, I want to determine if it's</pre>
<pre>because the file doesn't exist.</pre>
<pre>
</pre>
<pre>It isn't a show stopper to me, I can return "" in case of any error, but it</pre>
<pre>isn't optimal.</pre>
<pre>
</pre>
<pre>Cheers,</pre>
<pre>Volker</pre>
</blockquote>
<p>Why do you need to test according to io.error? <br>
</p>
<p>io.error will only "materialize" logical failure. Which takes
place further up in the tree.</p>
</blockquote>
<div>I don't get it.</div>
</blockquote>
<p>This looks clear to me at least. io.error does not pop up out of
thin air.</p>
<p>You get an io.error when there is an error in open_input. In the
snippet I sent, when there is an error on opening the file,</p>
<p> OpenInputResult =
ok(InputStream)</p>
<p>fails. Then the other branch of the disjunct is processed and you
get the error message through:<br>
</p>
<p> OpenInputResult =
error(OpenInputError)</p>
<p>Now, there is no use testing against io.error, as long as you can
test against OpenInputResult, which is unified before the
disjunction is processed (one node up relative to the nodes of the
above disjunct unifications).</p>
<blockquote type="cite"
cite="mid:026071b30d0ce46a48154847697e754c533d4907.camel@volker-wysk.de">
<blockquote type="cite" style="margin:0 0 0 .8ex; border-left:2px
#729fcf solid;padding-left:1ex">
<p>So you just need to test against open_input out-mode argument
values.<br>
</p>
<p>Have you tried something along these lines?</p>
</blockquote>
<div>I need to distinguish between "file does not exist" errors
and other errors. I want the other errors stay errors, which
will get reported later. </div>
</blockquote>
<p>In this case, you can return ReadInputError instead of ResultStr
(or throwing an exception in the second disjunct after
read_file_as_string).</p>
<p>And analyse ReadInputError later (just modify my_pred
accordingly).</p>
<blockquote type="cite"
cite="mid:026071b30d0ce46a48154847697e754c533d4907.camel@volker-wysk.de">
<div>Only "file does not exist" errors should be ignored.</div>
</blockquote>
Fabrice<br>
</body>
</html>