Reloading .pm files / returning error when compile failed

git-svn-id: https://svn.fhem.de/fhem/trunk/fhem@1462 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
rudolfkoenig 2012-04-17 11:10:32 +00:00
parent 4fb8ba3466
commit 059c0ab0b7
2 changed files with 6 additions and 4 deletions

View File

@ -1539,12 +1539,11 @@ CommandReload($$)
Log 5, "Loading $file";
no strict "refs";
eval {
my $ret = eval {
my $ret=do "$file";
if(!$ret) {
Log 1, "reload: Error:Modul $param deactivated:\n $@";
use strict "refs";
return "$@";
return $@;
}
# Get the name of the initialize function. This may differ from the
@ -1556,12 +1555,14 @@ CommandReload($$)
last;
}
}
$ret = &{ "${fnname}_Initialize" }(\%hash);
&{ "${fnname}_Initialize" }(\%hash);
$m = $fnname;
return undef;
};
use strict "refs";
return "$@" if($@);
return $ret if($ret);
my ($defptr, $ldata);
if($modules{$m}) {

View File

@ -1560,6 +1560,7 @@ FW_style($$)
print FH $FW_data;
close(FH);
my $ret = FW_fC("rereadcfg") if($fName eq $attr{global}{configfile});
$ret = FW_fC("reload $1") if($fName =~ m,.*/([^/]*).pm,);
$ret = ($ret ? "<h3>ERROR:</h3><b>$ret</b>" : "Saved the file $fName");
FW_style("style list", $ret);
$ret = "";