/** * Method to run the application routines. * * @return void * * @since 1.0 */ public function doExecute() { try { $controller = $this->router->getController($this->get('uri.route')); $controller->execute(); } catch (\Exception $e) { $this->setErrorHeader($e); $data = ['error' => true, 'message' => $e->getMessage()]; $this->setBody(json_encode($data)); } }
/** * Execute the Application * * @return void */ public function doExecute() { try { $controller = $this->router->getController($this->get("uri.route")); $this->setBody($controller->execute()); } catch (\Exception $e) { if ($e->getCode() === 404) { http_response_code(404); } $this->setBody($e->getMessage()); } }
/** * Method to run the application routines. * * @return void * * @since 1.0 */ public function doExecute() { try { $controller = $this->router->getController($this->get('uri.route')); $controller->execute(); } catch (\Exception $e) { // Log the error for reference $this->getLogger()->error($e->getMessage(), ['trace' => $e->getTraceAsString()]); $this->setErrorHeader($e); $data = ['error' => true, 'message' => $e->getMessage()]; $this->setBody(json_encode($data)); } }