summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorgueux <gueux@gueux.org>2010-04-06 14:41:20 +0000
committergueux <gueux@gueux.org>2010-04-06 14:41:20 +0000
commitc73ab2f60c8c8777085f4db463c6f43968c87b39 (patch)
tree8d7a752f740f2e9f235789313cf3f85236b76c59
parentdcb513923ec7f4c853d926dfeab62374e124b1ea (diff)
DATE ISO8601 format error
-rw-r--r--DateTime-Format-ISO8601-ParseDateTag/lib/DateTime/Format/ISO8601/ParseDateTag.pm3
-rw-r--r--flacinfo8
-rw-r--r--test/parse-date-test.pl8
3 files changed, 10 insertions, 9 deletions
diff --git a/DateTime-Format-ISO8601-ParseDateTag/lib/DateTime/Format/ISO8601/ParseDateTag.pm b/DateTime-Format-ISO8601-ParseDateTag/lib/DateTime/Format/ISO8601/ParseDateTag.pm
index 0cbbf74..8543f3f 100644
--- a/DateTime-Format-ISO8601-ParseDateTag/lib/DateTime/Format/ISO8601/ParseDateTag.pm
+++ b/DateTime-Format-ISO8601-ParseDateTag/lib/DateTime/Format/ISO8601/ParseDateTag.pm
@@ -113,6 +113,9 @@ sub parse {
else {
return "Released $tmp";
};
+ }
+ else {
+ die "Error: \"$_[0]\" is not a date in ISO8601 format."
};
}
diff --git a/flacinfo b/flacinfo
index 24c19d0..aa7dfaa 100644
--- a/flacinfo
+++ b/flacinfo
@@ -4,7 +4,7 @@ use strict;
use warnings;
use Audio::Scan;
use DateTime::Format::ISO8601::ParseDateTag;
-#use Lingua::EN::Numbers::Ordinate;
+use Error qw(:try);
if ($#ARGV == -1) {
exit 0
@@ -154,12 +154,14 @@ default("PRODUCER", "Producer");
if (defined $tags->{ "DATE" }) {
my $dateparser = DateTime::Format::ISO8601::ParseDateTag->new;
if ( ref($tags->{ "DATE" }) ne 'ARRAY' ) {
- print $dateparser->parse($tags->{ "DATE" }) . "\n";
+ try { print $dateparser->parse($tags->{ "DATE" }) . "\n"; }
+ catch Error with { print "$@" };
}
else {
my $array = $tags->{ "DATE" };
foreach my $var (@$array) {
- print $dateparser->parse($var) . "\n";
+ try { print $dateparser->parse($var) . "\n"; }
+ catch Error with { print "$@" };
};
};
}
diff --git a/test/parse-date-test.pl b/test/parse-date-test.pl
index efc9996..a161016 100644
--- a/test/parse-date-test.pl
+++ b/test/parse-date-test.pl
@@ -25,12 +25,8 @@ my @test = (
foreach my $t (@test) {
print $t . " ### ";
- try {
- print $parser->parse($t) . "\n";
- }
- catch Error with {
- print "Error: $@"
- };
+ try { print $parser->parse($t) . "\n"; }
+ catch Error with { print "Error: $@" };
}
## incorrect