How to handle 404 pages in slim 4 which is inside in sub folder

Hi There,

My Current slim 4 project is inside subfolder and the 404 pages is not working and ending up in error

<?php

namespace App\Exceptions;

use Throwable;
use ReflectionClass;
use Slim\Views\Twig;
use Slim\Handlers\ErrorHandler;
use Slim\Exception\HttpNotFoundException;
use Psr\Http\Message\ServerRequestInterface;
use Psr\Http\Message\ResponseFactoryInterface;

class Handler
{
    protected $responseFactory;

    protected $view;

    public function __construct(ResponseFactoryInterface $responseFactory, Twig $view)
    {
        $this->responseFactory = $responseFactory;
        $this->view = $view;
    }

    public function __invoke(ServerRequestInterface $request, Throwable $exception)
    {
        if (method_exists($this, $handler = 'handle' . (new ReflectionClass($exception))->getShortName())) {
            return $this->{$handler}($request);
        }

        throw $exception;
    }


    public function handleHttpNotFoundException(ServerRequestInterface $request)
    {   

        // If Triling slash
        return $this->view->render(
            $this->responseFactory->createResponse(),
            '404.twig'
        )
            ->withStatus(404);
    }
}

Fatal error: Uncaught TypeError: Return value of Slim\Handlers\Strategies\RequestResponse::__invoke() must implement interface Psr\Http\Message\ResponseInterface, null returned in /home1/vendor/slim/slim/Slim/Handlers/Strategies/RequestResponse.php:43 Stack trace: #0 /home1/plugmatt/public_html/plugins/vendor/slim/slim/Slim/Routing/Route.php(384): Slim\Handlers\Strategies\RequestResponse->__invoke(Array, Object(Slim\Psr7\Request), Object(Slim\Psr7\Response), Array) #1 /home1/plugmatt/public_html/plugins/vendor/slim/slim/Slim/MiddlewareDispatcher.php(81): Slim\Routing\Route->handle(Object(Slim\Psr7\Request)) #2 /home1/plugmatt/public_html/plugins/vendor/slim/slim/Slim/MiddlewareDispatcher.php(81): Slim\MiddlewareDispatcher->handle(Object(Slim\Psr7\Request)) #3 /home1/plugmatt/public_html/plugins/vendor/slim/slim/Slim/Routing/Route.php(341): Slim\MiddlewareDispatcher->handle(Object(Slim\Psr7\Request)) #4 /home1/vendor/slim/slim/Slim/Routing/RouteRunner.php(84): Slim\ in /home1/vendor/slim/slim/Slim/Handlers/Strategies/RequestResponse.php on line 43

How do I handle 404?