/** * @param Exception $exception * @return XmlRpcResponse */ public function createErrorResponse(Exception $exception) { if (!$exception instanceof RpcExceptionInterface) { $exception = new RpcException(); } $body = $this->serializer->serialize(['faultCode' => $exception->getCode(), 'faultString' => $exception->getMessage()]); return new XmlRpcResponse($body, 200, []); }
/** * @param Exception $exception * @return JsonRpcResponse */ public function createErrorResponse(\Exception $exception) { if (!$exception instanceof RpcExceptionInterface) { $exception = new RpcException(); } $body = $this->serializer->serialize(['jsonrpc' => '2.0', 'error' => ['code' => $exception->getCode(), 'message' => $exception->getMessage(), 'data' => $exception->getData()], 'id' => null]); return new JsonRpcResponse($body, 200, []); }