From 7eac929532b687b6df5d31a9e23178201f12667d Mon Sep 17 00:00:00 2001 From: Alex 'AdUser' Z Date: Mon, 23 Jul 2018 17:50:09 +1000 Subject: [PATCH] * Subtitle::BASE->from_file : return undef on error --- bin/ssa-retime | 6 ++++-- lib/Subtitle/BASE.pm | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/bin/ssa-retime b/bin/ssa-retime index 6e7dbbd..733fa93 100755 --- a/bin/ssa-retime +++ b/bin/ssa-retime @@ -103,8 +103,10 @@ if ($mode eq 'framerate') { } my $ssa = Subtitle::SSA->new(debug => !!$opts{loglevel}); -if ($ssa->from_file($opts{infile}) < 0) { - warn "Can't parse input file: $opts{infile}\n"; +unless ($ssa->from_file($opts{infile})) { + foreach my $line (@{ $ssa->{log} }) { + print $line, "\n"; + } exit 1; } diff --git a/lib/Subtitle/BASE.pm b/lib/Subtitle/BASE.pm index 36439f7..9b7dfef 100644 --- a/lib/Subtitle/BASE.pm +++ b/lib/Subtitle/BASE.pm @@ -34,7 +34,7 @@ sub from_string { sub from_file { my ($self, $path) = @_; open my $FH, '<', $path - or return -1; + or return $self->log(error => "can't open file: $path -- $!"); my @lines = <$FH>; close $FH; return unless @lines; # empty file?