[m-users.] Error handling in io module

Volker Wysk <[email protected]>
Newsgroups gmane.comp.lang.mercury.general
Message-ID <[email protected]>
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

_______________________________________________
users mailing list
[email protected]
https://lists.mercurylang.org/listinfo/users
signature.asc (application/pgp-signature, 833 B)
-----BEGIN PGP SIGNATURE-----

iQIzBAABCgAdFiEE6QXGh82Ov3+2nrxp+K4ydFOsHoUFAmPnxjQACgkQ+K4ydFOs
HoXT5A//eGv0zoE5vFC4a9Wtl+anxGztYQnV3OlSJwsyFCtf4pnzYGd/Ae3fOiWJ
MjJiawyxZuVMIamWU89dwbXT3BjCBh+uCRJfJco957bisUymUcIn343xFxrPVeDT
bv4ZS3FWt600MHdCrlqC3pDXwmQfufc0A9fGH1oyqj+KWjRSL1zQ+1Jvu0kYSOtJ
5FSBIyV1XlF8HIP6/shwoiWGSK4DQw0Qn0oEhZMnJsyVnRL4vJISAv/E2CJpQvs1
mnA+WKJ0nHKnRsxNoRB6JSl6YZs7yYrTzWqgq41AVex9+z7Krkt30z+jIIU5Izns
BPfDuDhVCXNP7WgCauvBxv4+U99aNv1yxhxcjk3RJ3mkyA/PMt9E4Upe7Mpukk6W
651HXdQh9cchi6VYuHy8basdVT6BX3f0mSQh1Svf65zqSH2IElDtpG6KIrFljiGn
JQPOkbjeyNsSulYH7cm2tXG/B2H85jWGhW/XPr5+8RPmmElN/QTOLM9CPjZbNrmt
QMy2mEBm4jvK9zi4TjrqUJHsdjbiE7eSd/CjAgHdZXx3tgrSsoYCeTImGFYw53u7
HQgKU5Nc02zpKIlNSxcomsuZXwMuBjik5agh6IEcvF+ggvB6jrdEkZnrJzyBJESW
sj/qrXM0fSl7QEeRCLMr2sa3QkeAYgyMbKexr3UaZzRDtpNYs/Q=
=n2Wf
-----END PGP SIGNATURE-----
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.