[m-users.] io.error type

Sean Charles (emacstheviking) objitsu at gmail.com
Fri Feb 4 20:50:07 AEDT 2022


What backend are you using...C ? You could wrap 'fstat' or something to do the job... I must confess to a little surprise that we seem to have no library function to test for 'file exists' but in a way, that's the end developers issue, Mercury is not about covering all things to all men on all platforms as I understand it.



> On 4 Feb 2022, at 09:03, Volker Wysk <post at volker-wysk.de> wrote:
> 
> 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 <mailto: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 <mailto:users at lists.mercurylang.org>
>>> https://lists.mercurylang.org/listinfo/users <https://lists.mercurylang.org/listinfo/users>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mercurylang.org/archives/users/attachments/20220204/4f0010bb/attachment.html>


More information about the users mailing list