From b3cbce33971fd5eb180dd9733fca955f46dcd722 Mon Sep 17 00:00:00 2001 From: Ellert Date: Fri, 8 Mar 2024 22:33:45 +0000 Subject: [PATCH] 74_AutomowerConnect: Common.pm: replace 'die' statement. git-svn-id: https://svn.fhem.de/fhem/trunk@28619 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- fhem/lib/FHEM/Devices/AMConnect/Common.pm | 35 ++++++++++++++++------- 1 file changed, 25 insertions(+), 10 deletions(-) diff --git a/fhem/lib/FHEM/Devices/AMConnect/Common.pm b/fhem/lib/FHEM/Devices/AMConnect/Common.pm index 9f06c8dd0..913dfb695 100644 --- a/fhem/lib/FHEM/Devices/AMConnect/Common.pm +++ b/fhem/lib/FHEM/Devices/AMConnect/Common.pm @@ -2083,21 +2083,36 @@ sub readMap { if ( $filename and -e $filename ) { - open my $fh, '<:raw', $filename or die $!; - my $content = ''; + if ( open my $fh, '<:raw', $filename ) { - while (1) { + my $content = ''; - my $success = read $fh, $content, 1024, length($content); - die $! if not defined $success; - last if not $success; + while (1) { + + my $success = read $fh, $content, 1024, length( $content ); + + if ( not defined $success ) { + + close $fh; + Log3 $name, 1, "$iam read file \"$filename\" with error $!"; + return; + + } + + last if not $success; + + } + + close $fh; + $hash->{helper}{MAP_CACHE} = $content; + Log3 $name, 4, "$iam file \"$filename\" content length: ".length( $content ); + + } else { + + Log3 $name, 1, "$iam open file \"$filename\" with error $!"; } - close $fh; - $hash->{helper}{MAP_CACHE} = $content; - Log3 $name, 5, "$iam file \"$filename\" content length: ".length($content); - } else { Log3 $name, 2, "$iam file \"$filename\" does not exist.";