[m-users.] io.error type

Volker Wysk post at volker-wysk.de
Fri Feb 4 20:03:17 AEDT 2022


Am Freitag, dem 04.02.2022 um 08:27 +0000 schrieb Sean Charles (emacstheviking):
> Hi Volker,
> I just try to open files, if it fails, I use error_message() to explain why and leave it at that...is there some *specific* reason you need to know the file didn't exist?

In MoinMoin, there sometimes is no "current" file, and in this case it should be treated as being empty. Other errors should be reported properly. So I need to distinguish a "file doesn't exist" error from other errors.
Bye,V.W.
> 
> > On 4 Feb 2022, at 07:05, Volker Wysk <post at volker-wysk.de> wrote:
> > 
> > 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
> > _______________________________________________
> > users mailing list
> > users at lists.mercurylang.org
> > https://lists.mercurylang.org/listinfo/users
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mercurylang.org/archives/users/attachments/20220204/00e365df/attachment.html>
-------------- 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/00e365df/attachment.sig>


More information about the users mailing list