[m-rev.] for review: Introduce io.system_error to io.m public interface.
Julien Fischer
jfischer at opturion.com
Tue Aug 23 16:01:21 AEST 2022
On Tue, 23 Aug 2022, Peter Wang wrote:
> On Mon, 22 Aug 2022 22:00:53 +1000 Julien Fischer <jfischer at opturion.com> wrote:
>>> @@ -2044,15 +2057,61 @@
>>> % Interpreting I/O error messages.
>>> %
>>>
>>> - % Construct an error code including the specified error message.
>>> + % Construct an error value with the specified error message.
>>> + % The error value will not have an associated system error.
>>> %
>>> :- func make_io_error(string) = io.error.
>>>
>>> - % Look up the error message corresponding to a particular error code.
>>> + % Return an error message for the error value.
>>> %
>>> :- func error_message(io.error) = string.
>>> :- pred error_message(io.error::in, string::out) is det.
>>
>> These will now need to take the I/O state. strerror and FormatMessage depend
>> on the current locale. That's going to breaking change, although I think we can
>> live with that, given that most calls to error_message occur in contexts where
>> the I/O state is available anyway.
>>
>> Same goes for bunch of things in the implementation.
>> e.g system_error_errno_message, system_error_win32_error_message -- basically
>> anything that leads to call to strerror or FormatMessage.
>>
>
> Oh, I forgot about that.
>
> I don't want to break io.error_message as that would break a lot of code
> to fix basically a theoretical problem. In practice either no one cares
> about locales, or sets the locale once at the start of a program.
>
> I'd prefer if io.error_message and co. were made independent of the
> current locale. strerror_l() exists but isn't available everywhere yet.
>
> I'm going to revert the changes, and retrieve the system error message
> at the time that the io.error is constructed (with the I/O state).
> Deferring retrieving the error message is a minor optimisation at most.
That's fine.
...
> I think we should remove the colon in the fallback strings.
> Log messages like:
>
> unable to foobar: errno 123
> unable to foobar: System error 0x123
>
> look a bit better and less confusing without the extra colon.
No objection from me.
...
> Interdiff follows. I've cut out some uninteresting changes.
That's fine.
Julien.
More information about the reviews
mailing list