4848use Psr \Http \Message \ResponseInterface ;
4949use Psr \Http \Message \ServerRequestInterface ;
5050use Psr \Http \Server \RequestHandlerInterface ;
51+ use Throwable ;
5152
5253class RequestHandler implements RequestHandlerInterface {
5354 /** @var callable(ResponseInterface,ConfigSection) */
@@ -105,7 +106,8 @@ public function handle(
105106 }
106107
107108 protected function completeRequestHandling (
108- ServerRequestInterface $ request
109+ ServerRequestInterface $ request ,
110+ bool $ ignoreLogicErrors = false ,
109111 ):void {
110112 $ this ->setupResponse ($ request );
111113 $ this ->forceTrailingSlashes ($ request );
@@ -130,12 +132,19 @@ protected function completeRequestHandling(
130132
131133 $ this ->handleProtectedGlobals ();
132134
133- if (isset ($ this ->viewModel ) && $ this ->viewModel instanceof HTMLDocument) {
134- $ this ->handleHTMLDocumentViewModel ();
135+ try {
136+ if (isset ($ this ->viewModel ) && $ this ->viewModel instanceof HTMLDocument) {
137+ $ this ->handleHTMLDocumentViewModel ();
135138// $this->handleCsrf($request);
136- }
139+ }
137140
138- $ this ->handleLogicExecution ($ this ->logicAssembly );
141+ $ this ->handleLogicExecution ($ this ->logicAssembly );
142+ }
143+ catch (Throwable $ throwable ) {
144+ if (!$ ignoreLogicErrors ) {
145+ throw $ throwable ;
146+ }
147+ }
139148
140149// TODO: Why is this in the handle function?
141150 $ documentBinder = $ this ->serviceContainer ->get (Binder::class);
@@ -277,9 +286,6 @@ protected function handleHTMLDocumentViewModel():void {
277286
278287 foreach ($ expandedLogicAssemblyList as $ i => $ assembly ) {
279288 $ componentElement = $ expandedComponentList [$ i ];
280- if (!$ componentElement ) {
281- var_dump ($ assembly );die ();
282- }
283289 $ this ->handleLogicExecution ($ assembly , $ componentElement );
284290 }
285291 }
0 commit comments