[m-users.] io.error type

Volker Wysk post at volker-wysk.de
Fri Feb 4 18:05:54 AEDT 2022


Am Freitag, dem 04.02.2022 um 16:51 +1100 schrieb Julien Fischer:
> Hi,
> 
> On Fri, 4 Feb 2022, Volker Wysk wrote:
> 
> > The type io.error is abstract. It looks like the only thing that can be done
> > with it, is to create an error message. But I need to do something which
> > depends on which error it is. So how to find this out...?
> 
> You can't using the interface currently exported by the io module.
> The io.error type just holds an error message.  The implementation of
> the predicates in the io module internally uses a system_error type, but
> as its names suggests it is system specific and in any case isn't
> accesible to normal user code.
> 
> What is it that you are trying to do?

I want to read the contents of a file, using open_input,
read_file_as_string, close_input. In case the file doesn't exist, I want to
return an empty string. So, in case of an error, I want to determine if it's
because the file doesn't exist.

It isn't a show stopper to me, I can return "" in case of any error, but it
isn't optimal.

Cheers,
Volker
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: This is a digitally signed message part
URL: <http://lists.mercurylang.org/archives/users/attachments/20220204/c76b4d32/attachment.sig>


More information about the users mailing list