Thread overview | ||||||
---|---|---|---|---|---|---|
|
May 19, 2016 ErrorException thrown when errno is modified ? | ||||
---|---|---|---|---|
| ||||
Hello, I'm planning to call some posix functions core.sys.posix that may set the errno value in case of error. e.g. read() or write(). Checking the std.exception documentation I see that ErrnoException may be thrown when errors setting errno may occur. Does this affect the posix calls ? From what I saw in the code, it doesn't seam the case. Just making sure I'm correct. |
May 19, 2016 Re: ErrorException thrown when errno is modified ? | ||||
---|---|---|---|---|
| ||||
Posted in reply to chmike | On 05/19/2016 03:05 PM, chmike wrote:
> I'm planning to call some posix functions core.sys.posix that may set
> the errno value in case of error. e.g. read() or write().
>
> Checking the std.exception documentation I see that ErrnoException may
> be thrown when errors setting errno may occur. Does this affect the
> posix calls ?
>
> From what I saw in the code, it doesn't seam the case. Just making sure
> I'm correct.
I think the description for ErrnoException is a bit misleading. I'm fairly certain that there is no code running that watches errno and throws an ErrnoException whenever it gets set. Rather, code that calls C functions which set errno can/should use ErrnoException and the errnoEnforce helper function to make a nice Exception from an errno value.
|
May 19, 2016 Re: ErrorException thrown when errno is modified ? | ||||
---|---|---|---|---|
| ||||
Posted in reply to chmike | On Thursday, 19 May 2016 at 13:05:19 UTC, chmike wrote:
> Checking the std.exception documentation I see that ErrnoException may be thrown when errors setting errno may occur. Does this affect the posix calls ?
It just means the Phobos functions that use these functions (like std.file or std.socket) might throw the exception, not the C functions themselves.
|
May 19, 2016 Re: ErrorException thrown when errno is modified ? | ||||
---|---|---|---|---|
| ||||
Posted in reply to chmike | On Thursday, 19 May 2016 at 13:05:19 UTC, chmike wrote:
> Hello,
>
> I'm planning to call some posix functions core.sys.posix that may set the errno value in case of error. e.g. read() or write().
>
> Checking the std.exception documentation I see that ErrnoException may be thrown when errors setting errno may occur. Does this affect the posix calls ?
>
> From what I saw in the code, it doesn't seam the case. Just making sure I'm correct.
ErrnoException is the exception thrown by errnoEnforce, which is a convenient function for checking system calls.
D links to the same Posix functions that C does; their behavior is exactly the same (ie they don't throw).
|
Copyright © 1999-2021 by the D Language Foundation