public function processRequest(AphrontRequest $request, PhutilDeferredLog $access_log, AphrontHTTPSink $sink, MultimeterControl $multimeter)
 {
     $this->setRequest($request);
     list($controller, $uri_data) = $this->buildController();
     $controller_class = get_class($controller);
     $access_log->setData(array('C' => $controller_class));
     $multimeter->setEventContext('web.' . $controller_class);
     $request->setURIMap($uri_data);
     $controller->setRequest($request);
     // If execution throws an exception and then trying to render that
     // exception throws another exception, we want to show the original
     // exception, as it is likely the root cause of the rendering exception.
     $original_exception = null;
     try {
         $response = $controller->willBeginExecution();
         if ($request->getUser() && $request->getUser()->getPHID()) {
             $access_log->setData(array('u' => $request->getUser()->getUserName(), 'P' => $request->getUser()->getPHID()));
             $multimeter->setEventViewer('user.' . $request->getUser()->getPHID());
         }
         if (!$response) {
             $controller->willProcessRequest($uri_data);
             $response = $controller->handleRequest($request);
         }
     } catch (Exception $ex) {
         $original_exception = $ex;
         $response = $this->handleException($ex);
     }
     try {
         $response = $controller->didProcessRequest($response);
         $response = $this->willSendResponse($response, $controller);
         $response->setRequest($request);
         $unexpected_output = PhabricatorStartup::endOutputCapture();
         if ($unexpected_output) {
             $unexpected_output = pht("Unexpected output:\n\n%s", $unexpected_output);
             phlog($unexpected_output);
             if ($response instanceof AphrontWebpageResponse) {
                 echo phutil_tag('div', array('style' => 'background: #eeddff;' . 'white-space: pre-wrap;' . 'z-index: 200000;' . 'position: relative;' . 'padding: 8px;' . 'font-family: monospace'), $unexpected_output);
             }
         }
         $sink->writeResponse($response);
     } catch (Exception $ex) {
         if ($original_exception) {
             throw $original_exception;
         }
         throw $ex;
     }
     return $response;
 }
 public function processRequest(AphrontRequest $request, PhutilDeferredLog $access_log, AphrontHTTPSink $sink, MultimeterControl $multimeter)
 {
     $this->setRequest($request);
     list($controller, $uri_data) = $this->buildController();
     $controller_class = get_class($controller);
     $access_log->setData(array('C' => $controller_class));
     $multimeter->setEventContext('web.' . $controller_class);
     $request->setController($controller);
     $request->setURIMap($uri_data);
     $controller->setRequest($request);
     // If execution throws an exception and then trying to render that
     // exception throws another exception, we want to show the original
     // exception, as it is likely the root cause of the rendering exception.
     $original_exception = null;
     try {
         $response = $controller->willBeginExecution();
         if ($request->getUser() && $request->getUser()->getPHID()) {
             $access_log->setData(array('u' => $request->getUser()->getUserName(), 'P' => $request->getUser()->getPHID()));
             $multimeter->setEventViewer('user.' . $request->getUser()->getPHID());
         }
         if (!$response) {
             $controller->willProcessRequest($uri_data);
             $response = $controller->handleRequest($request);
             $this->validateControllerResponse($controller, $response);
         }
     } catch (Exception $ex) {
         $original_exception = $ex;
         $response = $this->handleException($ex);
     }
     try {
         $response = $this->produceResponse($request, $response);
         $response = $controller->willSendResponse($response);
         $response->setRequest($request);
         self::writeResponse($sink, $response);
     } catch (Exception $ex) {
         if ($original_exception) {
             throw $original_exception;
         }
         throw $ex;
     }
     return $response;
 }