public function respond(ServerRequest $request)
    {
        try
        {
            $response = $this->request($request)
                ->finalize()
                ->getResponse();
        }
        catch(\Exception $e)
        {
            if($failRoute = $this->failRoute)
            {
                $response = $this->execute($failRoute, array('exception' => $e, 'request' => $request), $request)
                    ->finalize()
                    ->getResponse();

                $this->failRoute = null;
            }
            else if($this->map->hasFailRoute())
            {
                $response = $this->execute($this->map->getFailRoute(), array('exception' => $e, 'request' => $request), $request)
                    ->finalize()
                    ->getResponse();
            }
            else
            {
                $message = '<pre><h2>['.get_class($e).'] '.$e->getMessage().'</h2>'.PHP_EOL;
                $message .= $e->getTraceAsString();

                $response = Response::createEmptyResponse()
                    ->setStatus(404)
                    ->setBody($message);
            }
        }

        return $response;
    }
public function respond(ServerRequest $request)
    {
        try
        {
            $response = $this->request($request)
                ->finalize()
                ->getResponse();
        }
        catch(\Exception $e)
        {
            if($failRoute = $this->failRoute)
            {
                $response = $this->execute($failRoute, array('exception' => $e, 'request' => $request), $request)
                    ->finalize()
                    ->getResponse();

                $this->failRoute = null;
            }
            else if($this->map->hasFailRoute())
            {
                $response = $this->execute($this->map->getFailRoute(), array('exception' => $e, 'request' => $request), $request)
                    ->finalize()
                    ->getResponse();
            }
            else
            {
                $message = '<pre><h2>['.get_class($e).'] '.$e->getMessage().'</h2>'.PHP_EOL;
                $message .= $e->getTraceAsString();

                $response = Response::createEmptyResponse()
                    ->setStatus(404)
                    ->setBody($message);
            }
        }

        return $response;
    }
public function respond ( ServerRequest $ request ) { try { $ response = $ this -> request ( $ request ) -> finalize ( ) -> getResponse ( ) ; } catch ( \ Exception $ e ) { if ( $ failRoute = $ this -> failRoute ) { $ response = $ this -> execute ( $ failRoute , array ( 'exception' => $ e , 'request' => $ request ) , $ request ) -> finalize ( ) -> getResponse ( ) ; $ this -> failRoute = null ; } else if ( $ this -> map -> hasFailRoute ( ) ) { $ response = $ this -> execute ( $ this -> map -> getFailRoute ( ) , array ( 'exception' => $ e , 'request' => $ request ) , $ request ) -> finalize ( ) -> getResponse ( ) ; } else { $ message = '<pre><h2>[' . get_class ( $ e ) . '] ' . $ e -> getMessage ( ) . '</h2>' . PHP_EOL ; $ message .= $ e -> getTraceAsString ( ) ; $ response = Response :: createEmptyResponse ( ) -> setStatus ( 404 ) -> setBody ( $ message ) ; } } return $ response ; }
Dispatch and return the response
Handle uncaught \Exedra\Exception\Exception
@param ServerRequest|null $request
@return Response
Dispatch and return the response Handle uncaught \ Exedra \ Exception \ Exception