Beispiel #1
0
 /**
  * Error handler for developer mode
  *
  * @param Bootstrap $bootstrap
  * @param \Exception $exception
  * @return bool
  */
 private function handleDeveloperMode(Bootstrap $bootstrap, \Exception $exception)
 {
     if ($bootstrap->isDeveloperMode()) {
         $this->_response->setHttpResponseCode(500);
         $this->_response->setHeader('Content-Type', 'text/plain');
         $this->_response->setBody($exception->getMessage() . "\n" . $exception->getTraceAsString());
         $this->_response->sendResponse();
         return true;
     }
     return false;
 }
Beispiel #2
0
 /**
  * Error handler for developer mode
  *
  * @param Bootstrap $bootstrap
  * @param \Exception $exception
  * @return bool
  */
 private function handleDeveloperMode(Bootstrap $bootstrap, \Exception $exception)
 {
     if ($bootstrap->isDeveloperMode()) {
         if (Bootstrap::ERR_IS_INSTALLED == $bootstrap->getErrorCode()) {
             try {
                 $this->redirectToSetup($bootstrap, $exception);
                 return true;
             } catch (\Exception $e) {
                 $exception = $e;
             }
         }
         $this->_response->setHttpResponseCode(500);
         $this->_response->setHeader('Content-Type', 'text/plain');
         $this->_response->setBody($this->buildContentFromException($exception));
         $this->_response->sendResponse();
         return true;
     }
     return false;
 }
Beispiel #3
0
 /**
  * Run application
  *
  * @return ResponseInterface
  */
 public function launch()
 {
     try {
         $areaCode = $this->_areaList->getCodeByFrontName($this->_request->getFrontName());
         $this->_state->setAreaCode($areaCode);
         $this->_objectManager->configure($this->_configLoader->load($areaCode));
         $this->_response = $this->_objectManager->get('Magento\\Framework\\App\\FrontControllerInterface')->dispatch($this->_request);
         // This event gives possibility to launch something before sending output (allow cookie setting)
         $eventParams = array('request' => $this->_request, 'response' => $this->_response);
         $this->_eventManager->dispatch('controller_front_send_response_before', $eventParams);
     } catch (\Exception $exception) {
         $message = $exception->getMessage() . "\n";
         try {
             if ($this->_state->getMode() == State::MODE_DEVELOPER) {
                 $message .= '<pre>';
                 $message .= $exception->getMessage() . "\n\n";
                 $message .= $exception->getTraceAsString();
                 $message .= '</pre>';
             } else {
                 $reportData = array($exception->getMessage(), $exception->getTraceAsString());
                 // retrieve server data
                 if (isset($_SERVER)) {
                     if (isset($_SERVER['REQUEST_URI'])) {
                         $reportData['url'] = $_SERVER['REQUEST_URI'];
                     }
                     if (isset($_SERVER['SCRIPT_NAME'])) {
                         $reportData['script_name'] = $_SERVER['SCRIPT_NAME'];
                     }
                 }
                 require_once $this->_filesystem->getPath(Filesystem::PUB_DIR) . '/errors/report.php';
                 $processor = new \Magento\Framework\Error\Processor($this->_response);
                 $processor->saveReport($reportData);
                 $this->_response = $processor->processReport();
             }
         } catch (\Exception $exception) {
             $message .= "Unknown error happened.";
         }
         $this->_response->setHttpResponseCode(500);
         $this->_response->setBody($message);
     }
     return $this->_response;
 }
Beispiel #4
0
 /**
  * Process report
  *
  * @return \Magento\Framework\App\Response\Http
  */
 public function processReport()
 {
     $this->pageTitle = 'There has been an error processing your request';
     $this->_response->setHttpResponseCode(503);
     $this->showErrorMsg = false;
     $this->showSentMsg = false;
     $this->showSendForm = false;
     $this->reportAction = $this->_config->action;
     $this->_setReportUrl();
     if ($this->reportAction == 'email') {
         $this->showSendForm = true;
         $this->sendReport();
     }
     $this->_response->setBody($this->_renderPage('report.phtml'));
     return $this->_response;
 }
 /**
  * {@inheritdoc}
  */
 public function setHttpResponseCode($code)
 {
     $pluginInfo = $this->pluginList->getNext($this->subjectType, 'setHttpResponseCode');
     if (!$pluginInfo) {
         return parent::setHttpResponseCode($code);
     } else {
         return $this->___callPlugins('setHttpResponseCode', func_get_args(), $pluginInfo);
     }
 }