Exemplo n.º 1
0
 /**
  * @param \Magento\Framework\App\RequestInterface $request
  * @param Server $soapServer
  * @param \Magento\Framework\Webapi\Exception $exception
  * @param \Magento\Framework\Locale\ResolverInterface $localeResolver
  * @param State $appState
  */
 public function __construct(\Magento\Framework\App\RequestInterface $request, Server $soapServer, \Magento\Framework\Webapi\Exception $exception, \Magento\Framework\Locale\ResolverInterface $localeResolver, State $appState)
 {
     $this->_soapCode = $exception->getOriginator();
     $this->_parameters = $exception->getDetails();
     $this->_wrappedErrors = $exception->getErrors();
     $this->stackTrace = $exception->getStackTrace() ?: $exception->getTraceAsString();
     $this->message = $exception->getMessage();
     $this->_request = $request;
     $this->_soapServer = $soapServer;
     $this->_localeResolver = $localeResolver;
     $this->appState = $appState;
 }
Exemplo n.º 2
0
 /**
  * Process API exception.
  *
  * Create report if not in developer mode and render error to send correct API response.
  *
  * @param \Exception $exception
  * @param int $httpCode
  * @return void
  * @SuppressWarnings(PHPMD.ExitExpression)
  */
 public function renderException(\Exception $exception, $httpCode = self::DEFAULT_ERROR_HTTP_CODE)
 {
     if ($this->_appState->getMode() == State::MODE_DEVELOPER || $exception instanceof \Magento\Framework\Webapi\Exception) {
         $this->renderErrorMessage($exception->getMessage(), $exception->getTraceAsString(), $httpCode);
     } else {
         $reportId = $this->_critical($exception);
         $this->renderErrorMessage(new Phrase('Internal Error. Details are available in Magento log file. Report ID: %1', $reportId), 'Trace is not available.', $httpCode);
     }
     exit;
 }
Exemplo n.º 3
0
 /**
  * Log information about exception to exception log.
  *
  * @param \Exception $exception
  * @return string $reportId
  */
 protected function _critical(\Exception $exception)
 {
     $reportId = uniqid("webapi-");
     $message = "Report ID: {$reportId}; Message: {$exception->getMessage()}";
     $code = $exception->getCode();
     $exception = new \Exception($message, $code, $exception);
     $this->_logger->critical($exception);
     return $reportId;
 }