Date: | Mon, 28 Feb 2005 22:38:05 +0100 |
From: | Max Maischein <corion [...] corion.net> |
To: | bug-DateTime [...] rt.cpan.org |
Subject: | (wishlist) DateTime 0.28 has bad error diagnostics for comparing uncomparable items |
While tracing some bad interaction with Template,
I was annoyed by the bad error diagnostics that DateTime has - it dies
with an unhelpful message instead of telling at least the values when a
comparison happens between one DateTime object and a second object.
The following program shows the ugly behaviour:
use DateTime;
DateTime->now < 1
DateTime gives an error location within itself, which doesn't help much,
and the diagnostic is bad, as it doesn't even tell I<what> values it
tried to compare.
The below patch is what I changed - one thing is to use Carp.pm, and the
other is to output the values in the scalar or whatever DateTime was
offended by. That way, one gets at least an indication of where the
error occurred.
-max
3a4
Show quoted text
> use Carp qw(croak);
1385c1386
< die "Cannot compare a datetime to a regular scalar"
---
Show quoted text > croak "Cannot compare a datetime to a regular scalar ($dt1 /$dt2)"