/** * 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; }
/** * 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(); }
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); }
/** * @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; }
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; }
/** * 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()); }
/** * @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)); } }
/** * 获取异常扩展信息 * 用于非调试模式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()); } }
/** * 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); }
/** * 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); } }
/** * 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; }