public function handle(ServerRequestInterface $request, ServerFrame $frame) : ResponseInterface
    {
        try {
            return $frame->next($request);

        } catch (HttpException $httpException) {

            // forward to login page for unauthorized urls
            if ($httpException instanceof HttpUnauthorized) {
                return $frame->responseFactory()->create(302)->withHeader('Location', $this->loginUri);
            }

            return $frame->responseFactory()->create(
                $httpException->getCode(),
                [],
                $httpException->getCode() . ' ' . $httpException->getMessage() . ': ' . $httpException->getInfo()
            );
        }
    }
public function handle(ServerRequestInterface $request, ServerFrame $frame) : ResponseInterface
    {
        try {
            return $frame->next($request);

        } catch (HttpException $httpException) {

            // forward to login page for unauthorized urls
            if ($httpException instanceof HttpUnauthorized) {
                return $frame->responseFactory()->create(302)->withHeader('Location', $this->loginUri);
            }

            return $frame->responseFactory()->create(
                $httpException->getCode(),
                [],
                $httpException->getCode() . ' ' . $httpException->getMessage() . ': ' . $httpException->getInfo()
            );
        }
    }
@param ServerRequestInterface $request
@param ServerFrame            $frame

@return ResponseInterface