Graceful destruction on errors where plugins don't compile or follow API.

This commit is contained in:
JT Smith 2002-06-06 04:24:36 +00:00
parent 337db77f48
commit 1ac2bbd738
3 changed files with 18 additions and 7 deletions

View file

@ -45,7 +45,8 @@ sub page {
}
if (exists $session{form}{op}) {
$cmd = "WebGUI::Operation::www_".$session{form}{op};
$operationOutput = &$cmd();
$operationOutput = eval($cmd);
WebGUI::ErrorHandler::warn("Non-existent operation called: $session{form}{op}.") if($@);
}
if (exists $session{form}{func} && exists $session{form}{wid}) {
if ($session{form}{wid} eq "new") {
@ -70,9 +71,11 @@ sub page {
.$session{form}{wid}."] on page '".$session{page}{title}."' [".$session{page}{pageId}."].");
} else {
$cmd = "WebGUI::Wobject::".${$wobject}{namespace};
$w = $cmd->new($wobject);
$w = eval{$cmd->new($wobject)};
WebGUI::ErrorHandler::fatalError("Couldn't instanciate wojbect: ${$wobject}{namespace}.") if($@);
$cmd = "www_".$session{form}{func};
$wobjectOutput = $w->$cmd;
$wobjectOutput = eval{$w->$cmd};
WebGUI::ErrorHandler::fatalError("Web method doesn't exist in wojbect: ${$wobject}{namespace} / $session{form}{func}.") if($@);
}
# $wobjectOutput = WebGUI::International::get(381); # bad error
}
@ -114,10 +117,13 @@ sub page {
%hash = (%{$wobject},%{$extra});
$wobject = \%hash;
$cmd = "WebGUI::Wobject::".${$wobject}{namespace};
$w = $cmd->new($wobject);
$w = eval{$cmd->new($wobject)};
WebGUI::ErrorHandler::fatalError("Couldn't instanciate wojbect: ${$wobject}{namespace}.") if($@);
if ($w->inDateRange) {
$contentHash{${$wobject}{templatePosition}} .= '<a name="'.${$wobject}{wobjectId}.'"></a>'
.$w->www_view."<p>\n\n";
$contentHash{${$wobject}{templatePosition}} .= '<a name="'.${$wobject}{wobjectId}.'"></a>';
$contentHash{${$wobject}{templatePosition}} .= eval{$w->www_view};
WebGUI::ErrorHandler::fatalError("No view method in wojbect: ${$wobject}{namespace}.") if($@);
$contentHash{${$wobject}{templatePosition}} .= "<p>\n\n";
}
}
$sth->finish;

View file

@ -33,7 +33,8 @@ sub process {
$output = $_[0];
foreach $macro (keys %{$session{macro}}) {
$cmd = "WebGUI::Macro::".$macro."::process";
$output = &$cmd($output);
$output = eval{&$cmd($output)};
WebGUI::ErrorHandler::fatalError("Processing failed on macro: $macro.") if($@);
}
return $output;
}

View file

@ -16,6 +16,7 @@ use DBI;
use Exporter;
use strict;
use Tie::CPHash;
use WebGUI::ErrorHandler;
use WebGUI::SQL;
our @ISA = qw(Exporter);
@ -118,6 +119,7 @@ sub _loadMacros {
$namespace = $1;
$cmd = "use WebGUI::Macro::".$1;
eval($cmd);
WebGUI::ErrorHandler::fatalError("Macro failed to compile: $namespace.") if($@);
$session{macro}{$namespace} = $namespace;
}
}
@ -139,8 +141,10 @@ sub _loadWobjects {
$namespace = $1;
$cmd = "use WebGUI::Wobject::".$namespace;
eval($cmd);
WebGUI::ErrorHandler::fatalError("Wobject failed to compile: $namespace.") if($@);
$cmd = "\$WebGUI::Wobject::".$namespace."::name";
$session{wobject}{$namespace} = eval($cmd);
WebGUI::ErrorHandler::fatalError("No name method in wobject: $namespace.") if($@);
}
}
closedir(DIR);