소스 검색

Warn rather than dying if open() fails

Zachary Kotlarek 13 년 전
부모
커밋
73d0a8325b
1개의 변경된 파일과 8개의 추가작업 그리고 7개의 파일을 삭제
  1. 8 7
      dmx/state.pl

+ 8 - 7
dmx/state.pl

@@ -178,14 +178,15 @@ while (1) {
 
 		# Grab the state from STATUS files
 		if ($file->{'type'} =~ /^STATUS/) {
-			my $text = undef();
+			my $text = '';
 			{
-				my $fh;
-				open($fh, $file->{'path'})
-				  or die('Unable to open ' . $file->{'path'} . "\n");
-				local $/;
-				$text = <$fh>;
-				close($fh);
+				if (!open(my $fh, $file->{'path'})) {
+					warn('Unable to open ' . $file->{'path'} . "\n");
+				} else {
+					local $/;
+					$text = <$fh>;
+					close($fh);
+				}
 			}
 
 			if ($file->{'type'} eq 'STATUS_PLAYING') {