[m-users.] Error handling in io module

Volker Wysk post at volker-wysk.de
Sun Feb 12 03:45:40 AEDT 2023


Hi.

I suggest to add a test to the io module, for an error being zero. Meaning
no error / success. This could be a constant, say "error_success", or a
predicate "error_is_success/1".

I'm in the situation that I need to test a system_error (an errno) for being
a success. The only way I've found is to create an io.error from it and call
get_system_error_name/2. For the zero error, this creates the "errno 0"
string. The errno.h header doesn't define an errno value for "success".

The created io.error is always a system error, and thus the call of
get_system_error_name/2 always succeeds. But the compiler doesn't get that
and it's necessary to do an ugly, non-needed unexpected/2 call or something
like that.

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/20230211/4dc3e1a6/attachment.sig>


More information about the users mailing list