monotone-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Monotone-devel] "throw usage(); " or "N(); " for argument checking?


From: LeJacq, Jean Pierre
Subject: Re: [Monotone-devel] "throw usage(); " or "N(); " for argument checking?
Date: Sun, 4 Jan 2009 12:52:02 -0500
User-agent: KMail/1.9.9

On Sunday 2009 January 04 11:41:46 Timothy Brownawell wrote:
> On Sun, 2009-01-04 at 11:24 -0500, LeJacq, Jean Pierre wrote:
> > On Saturday 2009 January 03 20:56:52 Timothy Brownawell wrote:
> > > Many commands check for eg the right number of arguments like so:
> > >
> > >   if (args.size() != 3)
> > >     throw usage(execid);
> > >
> > > where others do
> > >
> > >   N(args.size() == 0,
> > >     F("no arguments needed"));
> > >
> > >
> > > This ought to be made consistent, does anyone object to using the
> > > 'throw usage();' version everywhere?
> >
> > I recommend the inverse. Exceptions should be reserved for, well
> > "exceptional" situations. Validation of inputs doesn't fall into
> > this category and is more properly handled by normal control loops.
>
> "N(false, message)" results in "throw informative_faulure(message)", the
> question is what to throw rather than whether to throw.

Two considerations:

1. N() can always be modified to provide an alternate implementation,
   though I acknowledge that changing from throw semantics
   would be problematic. For example, adding logging before the throw.
2. N() is not the best choice for handling this to begin with.

-- 
JP




reply via email to

[Prev in Thread] Current Thread [Next in Thread]