示例#1
0
 /**
  * Starts application
  *
  * @access public
  * @return void
  */
 public function run()
 {
     try {
         $route = $this->router->getRoute();
         if ($route == null) {
             throw new HttpNotFoundException("Page not found!", 404);
         }
         $response = $this->getResponse($route['controller'], $route['action'], $route['args']);
         if (!$response instanceof Response) {
             throw new BadResponseException('Wrong type of Response!');
         }
     } catch (DatabaseException $e) {
         $errorMessage = 'Sorry for the inconvenience. We are working to resolve this issue.
         Thank you for your patience.';
         $code = 500;
     } catch (HttpNotFoundException $e) {
         $code = $e->getCode();
         $errorMessage = 'Page not found!';
     } catch (BadControllerException $e) {
         $errorMessage = 'Sorry for the inconvenience. We are working to resolve this issue.
         Thank you for your patience.';
         $code = 500;
     } catch (BadTokenException $e) {
         $errorMessage = $e->getMessage();
         $code = $e->getCode();
     } catch (SecurityException $e) {
         $errorMessage = 'Sorry for the inconvenience. We are working to resolve this issue.
         Thank you for your patience.';
         $code = 500;
     } catch (BadResponseException $e) {
         $errorMessage = 'Sorry for the inconvenience. We are working to resolve this issue.
         Thank you for your patience.';
         $code = 500;
     } catch (\Exception $e) {
         $errorMessage = 'Sorry for the inconvenience. We are working to resolve this issue.
         Thank you for your patience.';
         $code = 500;
     } finally {
         if (isset($e) || !isset($response)) {
             $response = MainException::handleForUser($e, array('code' => $code, 'message' => $errorMessage));
         }
     }
     $response->send();
 }