浏览代码

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
 		# Grab the state from STATUS files
 		if ($file->{'type'} =~ /^STATUS/) {
 		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') {
 			if ($file->{'type'} eq 'STATUS_PLAYING') {