On Tuesday, July 15, 2003, at 11:11 PM, Rick Measham wrote:

I'm an anti-fan of die. Die requires wrapping in eval or parsing the user's input before passing to ->parse_datetime, which is just crazy.

We should only throw errors on programmer error. For example:
        $dt->set( weekday => 'Friday' );
should error because there's no 'weekday' parameter for set().

However, we should return DateTime::Undef on user error:
$dt->set( day => 'Twenty-two' );
because it means that we can now test for DateTime::Undef, letting set() do the parsing of the user's input.

This is why you use exception objects, and throw different exceptions for user errors vs. programmer error.


David

--
David Wheeler                                     AIM: dwTheory
[EMAIL PROTECTED]                              ICQ: 15726394
http://kineticode.com/                         Yahoo!: dew7e
                                               Jabber: [EMAIL PROTECTED]
Kineticode. Setting knowledge in motion.[sm]



Reply via email to