Thread overview
ErrnoException
Feb 28, 2016
Jirka
Feb 28, 2016
Mike Parker
Feb 29, 2016
Jirka
Feb 29, 2016
Chris Wright
Mar 01, 2016
Jirka
Mar 01, 2016
Mike Parker
February 28, 2016
I have a question about ErrnoException. When I throw it (throw new ErrnoException()), won't it overwrite the errno value before it can capture it?
February 28, 2016
On Sunday, 28 February 2016 at 13:10:20 UTC, Jirka wrote:
> I have a question about ErrnoException. When I throw it (throw new ErrnoException()), won't it overwrite the errno value before it can capture it?

Its constructor [1] simply fetches the current errno and gets an error message from it.

[1] https://github.com/D-Programming-Language/phobos/blob/master/std/exception.d#L1491
February 29, 2016
On Sunday, 28 February 2016 at 14:59:22 UTC, Mike Parker wrote:
> On Sunday, 28 February 2016 at 13:10:20 UTC, Jirka wrote:
>> I have a question about ErrnoException. When I throw it (throw new ErrnoException()), won't it overwrite the errno value before it can capture it?
>
> Its constructor [1] simply fetches the current errno and gets an error message from it.
>
> [1] https://github.com/D-Programming-Language/phobos/blob/master/std/exception.d#L1491

Yes, that I understand, but the "new" operator can lead to other system calls (?), could they overwrite it?
February 29, 2016
On Mon, 29 Feb 2016 21:55:49 +0000, Jirka wrote:

> Yes, that I understand, but the "new" operator can lead to other system calls (?), could they overwrite it?

Yes. Most obviously, the GC uses malloc, which will set errno to ENOMEM on failure.
March 01, 2016
On Monday, 29 February 2016 at 23:41:51 UTC, Chris Wright wrote:
> On Mon, 29 Feb 2016 21:55:49 +0000, Jirka wrote:
>
>> Yes, that I understand, but the "new" operator can lead to other system calls (?), could they overwrite it?
>
> Yes. Most obviously, the GC uses malloc, which will set errno to ENOMEM on failure.

Ok, that would throw some OOM exception instead so I wouldn't need to bother with it, is there something else in the GC that would override it during class instance allocation? I am finding it weird that ErrnoException doesn't let you specify the errno value explicitly, you usually check it in your code anyway (e.g. for EINTR and repeat the operation and not throw this error).
March 01, 2016
On Tuesday, 1 March 2016 at 01:31:56 UTC, Jirka wrote:

>
> Ok, that would throw some OOM exception instead so I wouldn't need to bother with it, is there something else in the GC that would override it during class instance allocation? I am finding it weird that ErrnoException doesn't let you specify the errno value explicitly, you usually check it in your code anyway (e.g. for EINTR and repeat the operation and not throw this error).

An additional constructor that accepts and errno value sounds like a good potential PR.
March 01, 2016
On 3/1/16 12:44 AM, Mike Parker wrote:
> On Tuesday, 1 March 2016 at 01:31:56 UTC, Jirka wrote:
>
>>
>> Ok, that would throw some OOM exception instead so I wouldn't need to
>> bother with it, is there something else in the GC that would override
>> it during class instance allocation? I am finding it weird that
>> ErrnoException doesn't let you specify the errno value explicitly, you
>> usually check it in your code anyway (e.g. for EINTR and repeat the
>> operation and not throw this error).
>
> An additional constructor that accepts and errno value sounds like a
> good potential PR.

Yes, please file an enhancement request.

-Steve