- or download this
# in MyApp::Util
sub convert_datetime {
...
return undef if $@;
# No error, now we can convert the date (not shown)
}
- or download this
my $bogus_datetime = MyApp::Util->convert_datetime("FOO");
is ($bogus_datetime, undef, "convert_datetime doesn't blow up if sent
+bogus date");
- or download this
ok 141 - convert_datetime doesn't blow up if sent bogus date
Invalid date format: at /path/to/MyApp/Util.pm line 818.
eval {...} called at /path/to/MyApp/Util.pm line 818
MyApp::Util::convert_datetime("MyApp::Util", "FOO") called at t/Ut
+il.t line 297
...propagated at t/Util.t line 298.
- or download this
#!/usr/bin/env perl
...
use DateTime::Format::ISO8601;
eval {my $foo = DateTime::Format::ISO8601->parse_datetime("FOO");};
print "ERROR\n" if $@;