summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2011-03-04 17:13:18 +0100
committerDaniel Friesel <derf@finalrewind.org>2011-03-04 17:13:18 +0100
commit97ea33ec84ab05d8c2ac1cf669d90f3d81b835f4 (patch)
tree708916949404d5b7d4d40e4640b85ec575f317d9
parent8355e11c04784b90f343dfc6b835eb7aa9d37e6e (diff)
App::Dthumb::Data get: Return undef for invalid files
-rw-r--r--lib/App/Dthumb/Data.pm.PL5
-rwxr-xr-xt/29-app-dthumb-data.t4
2 files changed, 6 insertions, 3 deletions
diff --git a/lib/App/Dthumb/Data.pm.PL b/lib/App/Dthumb/Data.pm.PL
index 6ebea05..eaf914e 100644
--- a/lib/App/Dthumb/Data.pm.PL
+++ b/lib/App/Dthumb/Data.pm.PL
@@ -123,7 +123,8 @@ sub list_archived {
=head2 get($filename)
-Returns the exact content of share/$filename.
+Returns the exact content of share/$filename (undef if no such file was
+saved).
=cut
@@ -133,7 +134,7 @@ sub get {
my $data = $self->section_data($name);
if (not $data) {
- die("No such data: ${name}\n");
+ return undef;
}
$data = ${$data};
diff --git a/t/29-app-dthumb-data.t b/t/29-app-dthumb-data.t
index 42e9b41..7ca9f2d 100755
--- a/t/29-app-dthumb-data.t
+++ b/t/29-app-dthumb-data.t
@@ -12,7 +12,7 @@ my @files = grep { /^[^.]/ } readdir($share);
closedir($share);
plan(
- tests => 1 + scalar @files,
+ tests => 2 + scalar @files,
);
my $dthumb = App::Dthumb::Data->new();
@@ -26,3 +26,5 @@ for my $file (@files) {
is($dthumb->get($file), $data, "\$dthumb->get($file)");
}
+
+is($dthumb->get('404notfound'), undef, '$dthumb->get on non-existing file');