Example #1
1
 /**
  * Create new HttpResponse from exception.
  *
  * @param \Exception $exception
  *
  * @return HttpResponse
  */
 protected function createHttpResponseFromException(\Exception $exception)
 {
     $httpResponse = HttpResponse::create();
     $json = [];
     $json['jsonrpc'] = '2.0';
     $json['error'] = [];
     if ($exception instanceof Exceptions\ErrorException) {
         $json['error']['code'] = $exception->getCode();
         $json['error']['message'] = $exception->getMessage();
         if ($exception->getData()) {
             $json['error']['data'] = $exception->getData();
         }
         $json['id'] = $exception->getId();
     } else {
         $json['error']['code'] = -32603;
         $json['error']['message'] = 'Internal error';
         $json['id'] = null;
     }
     $httpResponse->headers->set('Content-Type', 'application/json');
     $httpResponse->setContent(json_encode($json));
     $httpResponse->setStatusCode(500);
     return $httpResponse;
 }
Example #2
0
 /**
  * Returns an array of details about this error
  *
  * @return Array
  */
 public function getDetails()
 {
     if (!$this->exception instanceof \r8\Exception) {
         return array();
     }
     return array("Exception" => '\\' . get_class($this->exception), "Description" => $this->exception->getDescription()) + $this->exception->getData();
 }
Example #3
0
 protected function _handleException(\Exception $e)
 {
     try {
         throw $e;
     } catch (\Requests_Exception $e) {
         if (is_resource($e->getData())) {
             $errNo = curl_errno($e->getData());
             switch ($errNo) {
                 case 7:
                     throw new ServiceUnavailableException($e->getMessage(), 503, $e);
                 case 28:
                     throw new RequestTimeoutException($e->getMessage(), 408, $e);
             }
         }
     } catch (ApiException $e) {
         throw $e;
     }
     throw new ServerApiException($e->getMessage(), 500, $e);
 }
 /**
  * {@inheritdoc}
  */
 protected function whatProvidesManageException(Pool $pool, $name, \Exception $exception)
 {
     if ($exception instanceof InvalidCreateRepositoryException) {
         $data = $exception->getData();
         if (isset($data['versions']) && !empty($data['versions'])) {
             $this->putArrayRepositoryConfig($data['versions'], $name, $pool);
             return;
         }
     }
     parent::whatProvidesManageException($pool, $name, $exception);
 }
 /**
  * Erstellt die Ausnahme mit der Möglichkeit zusätzliche Daten anzugeben
  * @param string $message
  * @param array $data
  * @param int $code
  * @param Exception $previous
  */
 public function __construct($message = '', array $data = array(), $code = 0, Exception $previous = null)
 {
     if (isset($previous)) {
         if ($message == '') {
             $message = $previous->getMessage();
         }
         if (count($data) == 0 && $previous instanceof Dragon_Application_Exception_Abstract) {
             $data = $previous->getData();
         }
         if ($code == 0) {
             $code = $previous->getCode();
         }
     }
     $this->_data = $data;
     parent::__construct($message, $code, $previous);
 }
Example #6
0
 /**
  * @param \Exception $exception
  * @return \Exception
  */
 protected function translateException(\Exception $exception)
 {
     if ($exception instanceof PayPalConfigurationException || $exception instanceof PayPalInvalidCredentialException || $exception instanceof PayPalMissingCredentialException || $exception instanceof PayPalConnectionException) {
         return new PayPalException($exception->getMessage() . 'Data: ' . $exception->getData(), $exception->getCode(), $exception);
     }
     return $exception;
 }
Example #7
0
 protected function logException($level, \Exception $exception)
 {
     $component = 'unknown';
     if ($this->job != null) {
         $component = $this->job->getComponent();
     }
     $exceptionId = $component . '-' . md5(microtime());
     $logData = ['exceptionId' => $exceptionId, 'exception' => $exception];
     // SyrupExceptionInterface holds additional data
     if ($exception instanceof SyrupExceptionInterface) {
         $logData['data'] = $exception->getData();
     }
     $this->logger->{$level}($exception->getMessage(), $logData);
     return $exceptionId;
 }
Example #8
0
 /**
  * Prints Error
  *
  * @param      $title
  * @param      $objectName
  * @param null $objectId
  * @param null $request
  * @param \Exception $exception
  */
 public static function printError($title, $objectName, $objectId = null, $request = null, $exception = null)
 {
     $data = null;
     if ($exception instanceof \PayPal\Exception\PayPalConnectionException) {
         $data = $exception->getData();
     }
     self::printOutput($title, $objectName, $objectId, $request, $data, $exception->getMessage());
 }
Example #9
0
 /**
  * @param \Exception $e
  * @return array
  */
 public static function renderException($e)
 {
     if ($e instanceof PayPal\ErrorResponseException) {
         return array('tab' => 'PayPalRequest', 'panel' => '<p><b>Request:</b></p>' . Nette\Diagnostics\Helpers::clickableDump($e->getData(), TRUE) . '<p><b>Response:</b></p>' . Nette\Diagnostics\Helpers::clickableDump($e->getResponse(), TRUE));
     }
 }
Example #10
0
 /**
  * 获取异常扩展信息
  * 用于非调试模式html返回类型显示
  * @param  \Exception $exception 
  * @return array                 异常类定义的扩展数据
  */
 private static function getExtendData(\Exception $exception)
 {
     $data = [];
     if ($exception instanceof Exception) {
         $data = $exception->getData();
     }
     return $data;
 }
 /**
  * Show Exception if debug mode.
  *
  * @param Exception $e
  */
 public function handleException(Exception $e)
 {
     if (Mage::getStoreConfig('iways_paypalplus/dev/debug')) {
         Mage::getSingleton('core/session')->addWarning($e->getData());
     }
 }
Example #12
0
 /**
  * Prints Error
  *
  * @param      $title
  * @param      $objectName
  * @param null $objectId
  * @param null $request
  * @param \Exception $exception
  * @param bool $forceConsole
  */
 public static function printError($title, $objectName, $objectId = null, $request = null, $exception = null, $forceConsole = false)
 {
     $data = null;
     if ($exception instanceof \BlockCypher\Exception\BlockCypherConnectionException) {
         $data = $exception->getData();
     }
     self::printOutput($title, $objectName, $objectId, $request, $data, $exception->getMessage(), $forceConsole);
 }
Example #13
0
 /**
  * Notify Exception
  * @param Exception $exception
  */
 public function notifyException(Exception $exception)
 {
     $data = array();
     if ($exception instanceof ErrorNotException) {
         $data['exception_data'] = $exception->getData();
     }
     if ($this->dump_session_data && isset($_SESSION)) {
         $data['SESSION'] = $_SESSION;
     }
     $this->notify($exception->getMessage(), null, $exception->getTrace(), array('params' => array('post' => $_POST, 'get' => $_GET, 'cookies' => $_COOKIE)), $_SERVER, $data);
     if (!is_null($this->previous_exception_handler)) {
         call_user_func($this->previous_exception_handler, $exception);
     }
 }
Example #14
0
 /**
  * compile error object to be returned
  *
  * @error 14609
  * @param Exception $error
  * @return array
  */
 protected final function compileError(Exception $error)
 {
     $e = array();
     if ($error instanceof Xapp_Rpc_Fault) {
         $e['code'] = $this->getFault($error->getCode());
     } else {
         $e['code'] = $error->getCode();
     }
     if (isset($GLOBALS['_RPC']) && isset($GLOBALS['_RPC']['OMIT_ERROR']) && (bool) $GLOBALS['_RPC']['OMIT_ERROR']) {
         $e['message'] = null;
     } else {
         $e['message'] = $error->getMessage();
         if ($error instanceof Xapp_Rpc_Fault && $error->hasData()) {
             $e['data'] = $error->getData();
         }
     }
     return $e;
 }