mscherer 5 years ago
parent
commit
978f889897
2 changed files with 19 additions and 3 deletions
  1. 18 3
      docs/Error/ErrorHandler.md
  2. 1 0
      src/Error/ErrorHandler.php

+ 18 - 3
docs/Error/ErrorHandler.md

@@ -14,7 +14,8 @@ Log::config('404', [
 ]);
 ]);
 ```
 ```
 
 
-Make sure your other log configs are scope-deactivated then to prevent them being logged twice:
+Make sure your other log configs are scope-deactivated then to prevent them being 
+logged twice (`config/app.php`):
 ```php
 ```php
     'Log' => [
     'Log' => [
         'debug' => [
         'debug' => [
@@ -28,7 +29,8 @@ Make sure your other log configs are scope-deactivated then to prevent them bein
     ],
     ],
 ```
 ```
 
 
-In your bootstrap, the following snippet just needs to include the ErrorHandler of this plugin:
+In your `config/bootstrap.php`, the following snippet just needs to include the 
+ErrorHandler of this plugin:
 ```php
 ```php
 // Switch Cake\Error\ErrorHandler to
 // Switch Cake\Error\ErrorHandler to
 use Tools\Error\ErrorHandler;
 use Tools\Error\ErrorHandler;
@@ -40,7 +42,7 @@ if ($isCli) {
 }
 }
 ```
 ```
 
 
-Also, if you use the new Application middleware, make sure to include it there:
+Also, make sure to switch out the middleware:
 ```php
 ```php
 use Cake\Http\BaseApplication;
 use Cake\Http\BaseApplication;
 // Switch Cake\Error\Middleware\ErrorHandlerMiddleware to
 // 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
 In that case you are having invalid links in your pages somewhere, which should be fixed.
 In that case you are having invalid links in your pages somewhere, which should be fixed.
 So those are considered actual errors here.
 So those are considered actual errors here.
 
 
+### Adding more exceptions
+
+In case you need custom 404 mappings for some additional custom exceptions, 
+make use of `log404` option in your `app.php`.
+It will overwrite the current defaults completely.
+```php
+    'Error' => [
+        'log404' => [
+            ... // List of FQCN class names
+        ],
+    ],
+```
+
 ### Tips
 ### Tips
 
 
 You can also set up a monitor to check for the internal 404s and alert (via email or alike).
 You can also set up a monitor to check for the internal 404s and alert (via email or alike).

+ 1 - 0
src/Error/ErrorHandler.php

@@ -32,6 +32,7 @@ class ErrorHandler extends CoreErrorHandler {
 	 * @param array $config The options for error handling.
 	 * @param array $config The options for error handling.
 	 */
 	 */
 	public function __construct(array $config = []) {
 	public function __construct(array $config = []) {
+		$config += (array)Configure::read('Error');
 		$config += [
 		$config += [
 			'errorLogger' => ErrorLogger::class,
 			'errorLogger' => ErrorLogger::class,
 		];
 		];