On Saturday, February 23, 2013 14:46:04 H. S. Teoh wrote: > I never liked the design of errno in C... its being a global makes > keeping track of errors a pain. It would be nice if the value of errno > were saved in the Exception object at the time the error was > encountered, instead of arbitrary amounts of code after, which may have > changed its value.
That's what std.exception.errnoEnforce and ErrnoException doe. The ErrnoException gets the error code when it's constructed. std.file.FileException does the same thing at least some of the time (depending on what caused the error). In the case of FileException, we should probably have subclasses for the main error codes that you might want to handle specially (so catching the explicitly would be useful), but we don't have that yet. I don't know what the new std.process is doing (I haven't look at it yet), but if it's throwing exceptions based on errno, it needs to at least put the error code in the exception and maybe have specific exception types if it would make sense to be catching exceptions from std.process based on what exactly went wrong. Get the value of errno after catching the exception is just asking for it, since who knows what code ran after the exception was originally thrown. - Jonathan M Davis