public function onJsonRpcException(GetExceptionResponseEvent $event)
 {
     $request = $event->getRequest();
     if (!$request instanceof JsonRpcRequestInterface) {
         return;
     }
     $exception = $event->getException();
     if ($exception instanceof InvalidMethodParametersException) {
         $exception = JsonRpcException::create(JsonRpcError::INVALID_PARAMS, $exception->getMessage(), $exception->getTrace());
     } elseif ($exception instanceof MethodNotFoundException) {
         $exception = JsonRpcException::create(JsonRpcError::METHOD_NOT_FOUND, $exception->getMessage(), $exception->getTrace());
     }
     if ($exception instanceof JsonRpcExceptionInterface) {
         $error = $exception->getJsonRpcError();
         if (!$this->debug) {
             $error = new JsonRpcError($error->getCode(), $error->getMessage());
         }
         $event->setResponse(new JsonRpcResponse($request->getId(), null, $error));
         return;
     }
     $data = $this->debug ? (object) ['trace' => $exception->getTrace()] : null;
     $error = new JsonRpcError(JsonRpcError::INTERNAL_ERROR, $event->getException()->getMessage(), $data);
     $jsonResponse = new JsonRpcResponse($request->getId(), null, $error);
     $event->setResponse($jsonResponse);
 }
 public function onException(GetExceptionResponseEvent $event)
 {
     $request = $event->getRequest();
     $exception = $event->getException();
     $this->logger->critical($exception->getMessage(), ['endpoint' => $request->getAttributes()->get('_endpoint'), 'method' => $request->getMethod(), 'parameters' => json_decode(json_encode($request->getParameters()), true)]);
 }