[m-users.] io.error type

Peter Wang novalazy at gmail.com
Sat Feb 5 12:04:05 AEDT 2022


On Fri, 04 Feb 2022 15:52:38 +0100 Volker Wysk <post at volker-wysk.de> wrote:
> Am Freitag, dem 04.02.2022 um 12:54 +0100 schrieb Fabrice Nicol:
> > So yes, errno codes could have been returned, if is_error had been 
> > publicly visible, but design decisions went against this.
> 
> How are the chances that this will be changed? Not being able to determine
> which error occured, is kind of grave.

I agree it would sometimes be useful to get a machine-usable reason for
an error. I think we should add something like:

        % Get a system-specific error code associated with an error,
        % if any. On C backends, the error code should be an errno
        % value.
        %
    :- pred system_error_code(io.error::in, int::out) is semidet.

        % Construct an error value with the specified error code and
        % message. The error code should match an error code from the
        % underlying platform, but this is not enforced.
        %
    :- func make_system_error(int, string) = io.error.

It will require knowledge of the platform you are running on, and some
foreign code to use, and will not be helpful for Java and C# backends.
That's acknowledged.

Peter


More information about the users mailing list