play.pl: exception handling
fix "file not found" error
This commit is contained in:
parent
6ba1657fd4
commit
c78c75783c
@ -96,7 +96,7 @@ sub cmd_play {
|
|||||||
return weechat::WEECHAT_RC_OK;
|
return weechat::WEECHAT_RC_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($path and open FH, "<", (($file !~ m"/") ? $path->match :
|
if ($path = $path->match and open FH, "<", (($file !~ m"/") ? $path :
|
||||||
weechat::config_get_plugin('dir')."/$file")) {
|
weechat::config_get_plugin('dir')."/$file")) {
|
||||||
while (<FH>) {
|
while (<FH>) {
|
||||||
s/[\r\n]*$//;
|
s/[\r\n]*$//;
|
||||||
@ -110,7 +110,7 @@ sub cmd_play {
|
|||||||
'play', $buffer);
|
'play', $buffer);
|
||||||
} else {
|
} else {
|
||||||
weechat::print($buffer, weechat::prefix('error').
|
weechat::print($buffer, weechat::prefix('error').
|
||||||
"Cannot open '$file': $!");
|
"Cannot open '$file'".($! ? ": $!" : ""));
|
||||||
return weechat::WEECHAT_RC_ERROR;
|
return weechat::WEECHAT_RC_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user