File tree Expand file tree Collapse file tree 2 files changed +14
-13
lines changed Expand file tree Collapse file tree 2 files changed +14
-13
lines changed Original file line number Diff line number Diff line change @@ -73,16 +73,17 @@ called at the beginning of the request process, you can use the
73
73
74
74
namespace App;
75
75
76
+ use Cake\Core\Configure;
77
+ use Cake\Error\Middleware\ErrorHandlerMiddleware;
76
78
use Cake\Http\BaseApplication;
77
79
use Cake\Http\MiddlewareQueue;
78
- use Cake\Error\Middleware\ErrorHandlerMiddleware;
79
80
80
81
class Application extends BaseApplication
81
82
{
82
83
public function middleware(MiddlewareQueue $middlewareQueue): MiddlewareQueue
83
84
{
84
85
// Bind the error handler into the middleware queue.
85
- $middlewareQueue->add(new ErrorHandlerMiddleware());
86
+ $middlewareQueue->add(new ErrorHandlerMiddleware(Configure::read('Error'), $this ));
86
87
87
88
// Add middleware by classname.
88
89
// As of 4.5.0 classname middleware are optionally resolved
Original file line number Diff line number Diff line change @@ -225,7 +225,7 @@ a ``missingWidget()`` controller method, and CakePHP would use
225
225
226
226
class ErrorController extends AppController
227
227
{
228
- protected function missingWidget(MissingWidgetException $error )
228
+ protected function missingWidget(MissingWidgetException $exception )
229
229
{
230
230
// You can prepare additional template context or trap errors.
231
231
}
@@ -265,11 +265,11 @@ error pages when this error is handled::
265
265
}
266
266
}
267
267
268
- // In config/app.php
269
- 'Error' => [
270
- 'exceptionRenderer' => 'App\ Error\AppExceptionRenderer' ,
271
- // ...
272
- ],
268
+ // In Application::middleware()
269
+ $middlewareQueue->add(new ErrorHandlerMiddleware(
270
+ [ 'exceptionRenderer' => AppExceptionRenderer::class] + Configure::read(' Error') ,
271
+ $this,
272
+ ));
273
273
// ...
274
274
275
275
The above would handle our ``MissingWidgetException ``,
@@ -315,11 +315,11 @@ override the ``_getController()`` method in your exception renderer::
315
315
}
316
316
}
317
317
318
- // in config/app.php
319
- 'Error' => [
320
- 'exceptionRenderer' => 'App\ Error\AppExceptionRenderer' ,
321
- // ...
322
- ],
318
+ // In Application::middleware()
319
+ $middlewareQueue->add(new ErrorHandlerMiddleware(
320
+ [ 'exceptionRenderer' => AppExceptionRenderer::class] + Configure::read(' Error') ,
321
+ $this,
322
+ ));
323
323
// ...
324
324
325
325
You can’t perform that action at this time.
0 commit comments