Hey Sohail,

2010/12/8 Sohail Somani <[email protected]>:
> On 10-12-08 11:19 AM, Koen Deforche wrote:
>> I've fixed WRegExp so that passing it an invalid regular expession
>> makes isValid() return false but does not throw an exception.
>>
>
> Is that how Wt works in general? C++ best practice would state that
> constructed objects should not be invalid and that constructors should
> throw.

In Wt::Dbo we throw exceptions, in Wt itself there is not much that
can go wrong (in this sense). If it is a misuse of the API we throw an
exception. If it is a problem with input (like this case), we mimic
the behaviour of Qt, which is usually to indicate the error using an
isValid() method. This is probably somewhat misguided and I would
agree it is more correct to throw an exception instead. Fortunately,
there is not alot of situations in Wt where an object construction can
leave the object in an invalid state.

Entirely personally, I find that a try {} catch block often breaks the
legibility of the code, and for plain methods I prefer a return type
check over an exception.

Regards,
koen

------------------------------------------------------------------------------
_______________________________________________
witty-interest mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/witty-interest

Reply via email to