public function serve(ConnectionInterface $conn, RequestInterface $request = null, array $parameters)
 {
     try {
         $application = $this->applications->get($parameters['application']);
         $conn->send((string) $application->execute($parameters['module'], $request));
         $conn->close();
     } catch (ApplicationNotFoundException $e) {
         $response = new Response(404, null, $e->getMessage());
         $conn->send((string) $response);
         $conn->close();
     } catch (\Exception $e) {
         $response = new Response(500, null, $e->getMessage());
         $conn->send((string) $response);
         $conn->close();
     }
 }
 /**
  * @expectedException OwlyCode\ReactBoard\Exception\ApplicationNotFoundException
  * @expectedExceptionMessage The requested foo application was not registered in the ApplicationServer.
  */
 public function testApplicationNotFound()
 {
     $repository = new ApplicationRepository($this->dispatcher);
     $this->assertSame($this->application, $repository->get('foo'));
 }