Additional logic to files iterator
oojacoboo opened this issue · 1 comments
oojacoboo commented
I've added the following to the foreach
loop to provide better feedback on errors. I wasn't getting any output when PHP was crashing in the Docker container. With the following, I'm able to target the problematic file and error that caused the issue.
foreach ($files as $file) {
try {
// @ - to suppress warnings,
if (!@include_once($file)) {
throw new \Exception($file . ' does not exist');
}
if (!file_exists($file)) {
throw new \Exception($file . ' does not exist');
}
require_once $file;
} catch (\Throwable $e) {
echo 'Message: ' . $e->getMessage() . \PHP_EOL;
echo 'File: ' . $file . \PHP_EOL;
}
}
DarkGhostHunter commented
Cool if you add a file with an error. Seems like this would be useful if you f*ck up in production. I'll add it later if you don't pull a PR first.