The new std.process is ready for review

Jonathan M Davis jmdavisProg at gmx.com
Sat Feb 23 16:31:06 PST 2013


On Saturday, February 23, 2013 19:21:26 Steven Schveighoffer wrote:
> On Sat, 23 Feb 2013 18:59:05 -0500, Jonathan M Davis <jmdavisProg at gmx.com>
> 
> wrote:
> > 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.
> 
> It uses strerror to get the errno string representation, and uses that as
> the message.
> 
> I think it should also save the error code.
> 
> In a past life, I had a SystemException type (this was C++), and anything
> that died because of an errno error would throw a derivative of that,
> containing an errno copy.  If we already have a base ErrnoException, we
> ProcessException probably should derive from that.

Possibly, but you have to be a bit careful with that. For instance, 
std.file.FileException is in a weird place, because sometimes a FileException 
comes from errno and sometimes not, which means that if it were made to derive 
from ErrnoException, it could be a problem. ProcessException may not have that 
problem, but that sort of issue should be considered when deciding its 
inheritance hierarchy. If we had multiple inheritance, it would be an easier 
decision, but we don't. But an minimum, there should be a way to access the 
error code from errno if that's where an exception originated from (even if 
it's just that it's an exception that has ErrnoException as its next).

- Jonathan M Davis


More information about the Digitalmars-d mailing list