www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - ErrorException thrown when errno is modified ?

reply chmike <christophe meessen.net> writes:
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
next sibling parent ag0aep6g <anonymous example.com> writes:
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
prev sibling next sibling parent Adam D. Ruppe <destructionator gmail.com> writes:
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
prev sibling parent Alex Parrill <initrd.gz gmail.com> writes:
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).
May 19 2016