/** * @return DebugModule */ public function handleResponseReadyData() { $result = $this; if (!$this->getIsEnabled()) { return $result; } $rpc = $this->getRpc(); $response = $rpc->getResponse(); $readyData = $response->getReadyData(); // readyData.debug if (!$this->getIsDebugEnabled()) { $response->unsetReadyDataKey('debug'); } else { $readyDataDebug = $response->getReadyDataKey('debug'); $readyDataDebug = RpcUtil::arrayEnsure($readyDataDebug, array('demoDebugModuleMessage' => 'foo ' . __METHOD__, 'isDebugEnabled' => true, 'rpc' => array('request' => $rpc->getRequest()->getData(), 'result' => $rpc->getResponse()->getResult(), 'hasException' => $rpc->getResponse()->hasException()))); if ($response->hasException()) { $readyDataDebug['errorInfo'] = RpcUtil::exceptionAsArray($response->getException(), true); } $response->setReadyDataKey('debug', $readyDataDebug); } return $result; }
/** * @param GatewayModuleException $exception * @return GatewayModule */ protected function _onErrorRawResponseEmitFailed(GatewayModuleException $exception) { $result = $this; // no valid request raw data $isDebugEnabled = $this->getIsDebugEnabled(); $isAutoEmitResponseEnabled = $this->getIsAutoEmitResponseEnabled(); if ($isAutoEmitResponseEnabled) { $responseData = array('result' => null, 'error' => RpcUtil::exceptionAsArray($exception, $isDebugEnabled)); $responseText = RpcUtil::jsonEncode($responseData, false); if (!is_string($responseText)) { $responseData = array('result' => null, 'error' => RpcUtil::exceptionAsArray($exception, false)); $responseText = RpcUtil::jsonEncode($responseData, false); } $headersList = array('HTTP/1.1 500 Internal Server Error'); $this->_emitResponseHeaders($headersList); echo (string) $responseText; return $result; } return $result; }
/** * @param \Exception $exception * @param bool $isDebugEnabled * @return array */ protected function _exportExceptionAsArray(\Exception $exception, $isDebugEnabled) { $error = RpcUtil::exceptionAsArray($exception, $isDebugEnabled); return $error; }