Skip to content

Improvement: Add an exception for assets not found #378

Description

@mirko-pagliai

Even with the plugin configured correctly, the browser may still request an asset that no longer exists.

This throws a MissingControllerException exception like this:

[Cake\Http\Exception\MissingControllerException] Controller class `Assets` could not be found. in /var/www/climat/vendor/cakephp/cakephp/src/Controller/ControllerFactory.php on line 335
Stack Trace:
- CORE/src/Controller/ControllerFactory.php:77
- CORE/src/Http/BaseApplication.php:360
- CORE/src/Http/Runner.php:86
- ROOT/vendor/cakephp/authorization/src/Middleware/AuthorizationMiddleware.php:132
- CORE/src/Http/Runner.php:82
- ROOT/vendor/cakephp/authentication/src/Middleware/AuthenticationMiddleware.php:106
- CORE/src/Http/Runner.php:82
- CORE/src/Http/Middleware/SessionCsrfProtectionMiddleware.php:126
- CORE/src/Http/Runner.php:82
- CORE/src/Http/Middleware/BodyParserMiddleware.php:157
- CORE/src/Http/Runner.php:82
- CORE/src/Routing/Middleware/RoutingMiddleware.php:118
- CORE/src/Http/Runner.php:82
- CORE/src/Routing/Middleware/AssetMiddleware.php:80
- CORE/src/Http/Runner.php:82
- APP/Middleware/HostHeaderMiddleware.php:57
- CORE/src/Http/Runner.php:82
- ROOT/vendor/markstory/asset_compress/src/Middleware/AssetCompressMiddleware.php:58
- CORE/src/Http/Runner.php:82
- CORE/src/Error/Middleware/ErrorHandlerMiddleware.php:115
- CORE/src/Http/Runner.php:82
- CORE/src/Http/Runner.php:60
- CORE/src/Http/Server.php:98
- ROOT/webroot/index.php:23
- [main]:

Request URL: /assets/css/auth.v1781021998.css?1781021998

However, this does not help, during logging/debugging, to distinguish different cases that use the same exception (e.g. a bot making random requests, a link to a non-existent controller, etc.)

Obviously, this can be resolved in your app in various ways, such as with the .htaccess file or via middleware.

However, I was wondering if it wouldn't be possible and useful to implement a specific exception for assets, such as MissingAssetException or AssetNotFoundException.

Thanks as always.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions