digitalmars.D.learn - ErrnoException
- Jirka (3/3) Feb 28 2016 I have a question about ErrnoException. When I throw it (throw
- Mike Parker (5/8) Feb 28 2016 Its constructor [1] simply fetches the current errno and gets an
- Jirka (3/11) Feb 29 2016 Yes, that I understand, but the "new" operator can lead to other
- Chris Wright (3/5) Feb 29 2016 Yes. Most obviously, the GC uses malloc, which will set errno to ENOMEM
- Jirka (7/12) Feb 29 2016 Ok, that would throw some OOM exception instead so I wouldn't
- Mike Parker (3/10) Feb 29 2016 An additional constructor that accepts and errno value sounds
- Steven Schveighoffer (3/13) Mar 01 2016 Yes, please file an enhancement request.
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?
Feb 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
Feb 28 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:Yes, that I understand, but the "new" operator can lead to other system calls (?), could they overwrite it?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
Feb 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.
Feb 29 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: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).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.
Feb 29 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.
Feb 29 2016
On 3/1/16 12:44 AM, Mike Parker wrote:On Tuesday, 1 March 2016 at 01:31:56 UTC, Jirka wrote:Yes, please file an enhancement request. -SteveOk, 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.
Mar 01 2016