From 8f7f2f72e6ec0e7323b3af65c3f51c89c5e485fb Mon Sep 17 00:00:00 2001 From: borisneubert Date: Fri, 3 Oct 2014 07:27:27 +0000 Subject: [PATCH] 57_Calendar: one more code line hardened against non-existent start or end times; evaluate error message returned from HttpUtils git-svn-id: svn://svn.code.sf.net/p/fhem/code/trunk@6661 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- fhem/FHEM/57_Calendar.pm | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/fhem/FHEM/57_Calendar.pm b/fhem/FHEM/57_Calendar.pm index 92890e5c2..6fda5b75d 100644 --- a/fhem/FHEM/57_Calendar.pm +++ b/fhem/FHEM/57_Calendar.pm @@ -639,7 +639,9 @@ sub isEnded { sub nextTime { my ($self,$t) = @_; - my @times= ( $self->{start}, $self->{end} ); + my @times= ( ); + push @times, $self->{start} if(defined($self->{start})); + push @times, $self->{end} if(defined($self->{end})); unshift @times, $self->{alarm} if($self->{alarm}); @times= sort grep { $_ > $t } @times; @@ -880,11 +882,12 @@ sub Calendar_GetUpdate($$) { my $type = $hash->{fhem}{type}; my $url= $hash->{fhem}{url}; + my $errmsg= ""; my $ics; if($type eq "url"){ #$ics= GetFileFromURLQuiet($url,10,undef,0,5) if($type eq "url"); - $ics= HttpUtils_BlockingGet( { url => $url, hideurl => 1, timeout => 10, } ); + ($errmsg, $ics)= HttpUtils_BlockingGet( { url => $url, hideurl => 1, timeout => 10, } ); } elsif($type eq "file") { if(open(ICSFILE, $url)) { while() { @@ -901,8 +904,8 @@ sub Calendar_GetUpdate($$) { } - if(!defined($ics) or ("$ics" eq "")) { - Log3 $hash, 1, "Calendar " . $hash->{NAME} . ": Could not retrieve file at URL"; + if(!defined($ics) or ("$ics" eq "") or ($errmsg ne "")) { + Log3 $hash, 1, "Calendar " . $hash->{NAME} . ": Could not retrieve file at URL. $errmsg"; return 0; }