mirror of
https://github.com/EQEmu/Server.git
synced 2025-12-13 14:41:28 +00:00
[Quests] Improve Quest Error Handling - Add back in process based syntax validation (#2646)
This commit is contained in:
parent
1338d21823
commit
6ddd5db480
@ -214,7 +214,6 @@ void Embperl::init_eval_file(void)
|
|||||||
"} else {"
|
"} else {"
|
||||||
// we 'my' $filename,$mtime,$package,$sub to prevent them from changing our state up here.
|
// we 'my' $filename,$mtime,$package,$sub to prevent them from changing our state up here.
|
||||||
" eval(\"package $package; my(\\$filename,\\$mtime,\\$package,\\$sub); \\$isloaded = 1; require './$filename'; \");"
|
" eval(\"package $package; my(\\$filename,\\$mtime,\\$package,\\$sub); \\$isloaded = 1; require './$filename'; \");"
|
||||||
" die $@ if ($@ && $@ !~ /did not return a true value/); "
|
|
||||||
// " print $@ if $@;"
|
// " print $@ if $@;"
|
||||||
/* "local *FH;open FH, $filename or die \"open '$filename' $!\";"
|
/* "local *FH;open FH, $filename or die \"open '$filename' $!\";"
|
||||||
"local($/) = undef;my $sub = <FH>;close FH;"
|
"local($/) = undef;my $sub = <FH>;close FH;"
|
||||||
@ -275,6 +274,25 @@ int Embperl::dosub(const char * subname, const std::vector<std::string> * args,
|
|||||||
FREETMPS;
|
FREETMPS;
|
||||||
LEAVE;
|
LEAVE;
|
||||||
|
|
||||||
|
// not sure why we pass this as blind args, strange
|
||||||
|
// check for syntax errors
|
||||||
|
if (args && !args->empty()) {
|
||||||
|
const std::string &filename = args->back();
|
||||||
|
std::string sub = subname;
|
||||||
|
if (sub == "main::eval_file" && !filename.empty() && File::Exists(filename)) {
|
||||||
|
BenchTimer benchmark;
|
||||||
|
std::string syntax_error = Process::execute(
|
||||||
|
fmt::format("perl -c {} 2>&1", filename)
|
||||||
|
);
|
||||||
|
LogQuests("Perl eval [{}] took [{}]", filename, benchmark.elapsed());
|
||||||
|
syntax_error = Strings::Trim(syntax_error);
|
||||||
|
if (!Strings::Contains(syntax_error, "syntax OK")) {
|
||||||
|
syntax_error += SvPVX(ERRSV);
|
||||||
|
throw syntax_error;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (error.length() > 0) {
|
if (error.length() > 0) {
|
||||||
std::string errmsg = "Perl runtime error: ";
|
std::string errmsg = "Perl runtime error: ";
|
||||||
errmsg += SvPVX(ERRSV);
|
errmsg += SvPVX(ERRSV);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user