Closed dogawaf closed 1 year ago
Hi hi
If I call a non existing route, Slim throws a HttpNotFoundException, but TYPO3 does not catch it, and the client finally gets a 500.
I would like to better handle Slim errors, maybe like that:
// in \B13\SlimPhp\Middleware\SlimInitiator::process try { return $app->handle($request); } catch (HttpException $e) { $errorController = GeneralUtility::makeInstance(ErrorController::class); return match ($e->getCode()) { 503 => $errorController->unavailableAction($request, $e->getMessage()), 500 => $errorController->internalErrorAction($request, $e->getMessage()), 404 => $errorController->pageNotFoundAction($request, $e->getMessage()), 403 => $errorController->accessDeniedAction($request, $e->getMessage()), default => throw $e, }; }
It's better because the configured TYPO3 errorHandlers will be triggered. One thing it's not cool, it is that the content-type of the request is not properly detected (html response instead of a json response).
What do you think @bmack ?
yeah, good idea. we could still use the codes as fallback, but if a error handler is configured, we should use that one. Care to create a PR?
Sure.
Hi hi
If I call a non existing route, Slim throws a HttpNotFoundException, but TYPO3 does not catch it, and the client finally gets a 500.
I would like to better handle Slim errors, maybe like that:
It's better because the configured TYPO3 errorHandlers will be triggered. One thing it's not cool, it is that the content-type of the request is not properly detected (html response instead of a json response).
What do you think @bmack ?