Skip to content

Commit 978f889

Browse files
committed
404s
1 parent a3d4a83 commit 978f889

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-3
lines changed

docs/Error/ErrorHandler.md

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ Log::config('404', [
1414
]);
1515
```
1616

17-
Make sure your other log configs are scope-deactivated then to prevent them being logged twice:
17+
Make sure your other log configs are scope-deactivated then to prevent them being
18+
logged twice (`config/app.php`):
1819
```php
1920
'Log' => [
2021
'debug' => [
@@ -28,7 +29,8 @@ Make sure your other log configs are scope-deactivated then to prevent them bein
2829
],
2930
```
3031

31-
In your bootstrap, the following snippet just needs to include the ErrorHandler of this plugin:
32+
In your `config/bootstrap.php`, the following snippet just needs to include the
33+
ErrorHandler of this plugin:
3234
```php
3335
// Switch Cake\Error\ErrorHandler to
3436
use Tools\Error\ErrorHandler;
@@ -40,7 +42,7 @@ if ($isCli) {
4042
}
4143
```
4244

43-
Also, if you use the new Application middleware, make sure to include it there:
45+
Also, make sure to switch out the middleware:
4446
```php
4547
use Cake\Http\BaseApplication;
4648
// Switch Cake\Error\Middleware\ErrorHandlerMiddleware to
@@ -67,6 +69,19 @@ Note that internally caused 404s (referrer is a page on the own site) are not tr
6769
In that case you are having invalid links in your pages somewhere, which should be fixed.
6870
So those are considered actual errors here.
6971

72+
### Adding more exceptions
73+
74+
In case you need custom 404 mappings for some additional custom exceptions,
75+
make use of `log404` option in your `app.php`.
76+
It will overwrite the current defaults completely.
77+
```php
78+
'Error' => [
79+
'log404' => [
80+
... // List of FQCN class names
81+
],
82+
],
83+
```
84+
7085
### Tips
7186

7287
You can also set up a monitor to check for the internal 404s and alert (via email or alike).

src/Error/ErrorHandler.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ class ErrorHandler extends CoreErrorHandler {
3232
* @param array $config The options for error handling.
3333
*/
3434
public function __construct(array $config = []) {
35+
$config += (array)Configure::read('Error');
3536
$config += [
3637
'errorLogger' => ErrorLogger::class,
3738
];

0 commit comments

Comments
 (0)