Skip to content

Commit

Permalink
Catch and log exceptions in local generator script
Browse files Browse the repository at this point in the history
  • Loading branch information
bencroker committed Dec 10, 2024
1 parent 059280c commit 2152c40
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
8 changes: 7 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
# Release Notes for Blitz

## 4.23.9 - 2024-12-10

### Changed

- The reasons why pages failed to be generated using the Local Generator are now logged when debug mode is enabled ([#737](https://github.com/putyourlightson/craft-blitz/issues/737)).

## 4.23.8 - 2024-12-06

### Changed

- More deployer settings are now redacted when generating a diagnostics report.
- The existence of cached files is checked before deletion, to prevent unnecessarily logged warnings ([#741](https://github.com/putyourlightson/craft-blitz/issues/741)).
- The existence of cached files is now checked before deletion, to prevent unnecessarily logged warnings ([#741](https://github.com/putyourlightson/craft-blitz/issues/741)).
- The `injectScriptEvent` variable is no longer defined in the global scope, for better compatibility with JavaScript libraries ([#747](https://github.com/putyourlightson/craft-blitz/issues/747)).

## 4.23.7 - 2024-11-15
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "putyourlightson/craft-blitz",
"description": "Intelligent static page caching for creating lightning-fast sites.",
"version": "4.23.8",
"version": "4.23.9",
"type": "craft-plugin",
"homepage": "https://putyourlightson.com/plugins/blitz",
"license": "proprietary",
Expand Down
9 changes: 8 additions & 1 deletion src/drivers/generators/local-generator-script.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use Amp\Parallel\Sync\Channel;
use craft\services\Plugins;
use craft\web\View;
use putyourlightson\blitz\Blitz;
use yii\base\Event;

/**
Expand Down Expand Up @@ -98,8 +99,14 @@ function() {
* @var craft\web\Application $app
*/
$app = require $root . '/vendor/craftcms/cms/bootstrap/web.php';
$success = false;

$success = $app->run() === 0;
try {
$success = $app->run() == 0;
} catch (Throwable $exception) {
$error = 'Page not cached because an error was encountered: ' . $exception->getMessage();
Blitz::$plugin->debug($error, [], $url);
}

yield $channel->send($success);
};

0 comments on commit 2152c40

Please sign in to comment.