@return Response

@throws DriverException If there is not response yet
960739
protected function getResponse()
    {
        try {
            $response = $this->client->getInternalResponse();
        } catch (BadMethodCallException $e) {
            // Handling Symfony 5+ behaviour
            $response = null;
        }

        if (null === $response) {
            throw new DriverException('Unable to access the response before visiting a page');
        }

        return $response;
    }
1221753
public function receiveNoWait()
    {
        if ($this->currentEnvelope) {
            throw new \RuntimeException(
                'AmqpQueueDriver: This driver has a message that was not acknowledged yet. A message must be processed and acknowledged before receiving new messages.'
            );
        }

        $this->dequeueingTimeMs = 0;

        $this->currentEnvelope = $this->queue->get();

        $msg = null;

        if (!$this->currentEnvelope) {
            return null;
        }

        $start = microtime(true);
        $deserializationContext = new DeserializationContext();

        /** @var QueueMessageInterface $msg */
        $msg = $this->getSerializer()->deserialize($this->currentEnvelope->getBody(), SerializableInterface::class, $this->format, $deserializationContext);

        foreach ($this->currentEnvelope->getHeaders() as $header => $value) {
            $msg->setHeader($header, $value);
        }

        // Calculate how long it took to deserilize the message
        $this->dequeueingTimeMs = (int) ((microtime(true) - $start) * 1000);

        return $msg;
    }
577847
public function doShow()
    {
        if ( ($this->exception instanceof ezcMvcRouteNotFoundException) || ($this->exception instanceof ezpContentNotFoundException ) )
        {
            // we want to return a 404 to the user
            $result = new ezcMvcResult;
            $result->status = new ezpRestHttpResponse( ezpHttpResponseCodes::NOT_FOUND, "Not Found" );
            return $result;
        }

        else if ( $this->exception instanceof ezpOauthBadRequestException )
        {
            $result = new ezcMvcResult;
            $result->status = new ezpRestOauthErrorStatus( $this->exception->errorType, $this->exception->getMessage() );
            $result->variables['message'] = $this->exception->getMessage();
            return $result;
        }
        else if ( $this->exception instanceof ezpOauthRequiredException )
        {
            $result = new ezcMvcResult;
            $result->status = new ezpOauthRequired( "eZ Publish REST", $this->exception->errorType, $this->exception->getMessage() );
            $result->variables['message'] = $this->exception->getMessage();
            return $result;
        }
        else if ( $this->exception instanceof ezpContentAccessDeniedException )
        {
            $result = new ezcMvcResult;
            $result->variables['message'] = $this->exception->getMessage();
            $result->status = new ezpRestHttpResponse( ezpHttpResponseCodes::FORBIDDEN, $this->exception->getMessage() );
            return $result;
        }
        else if ( $this->exception instanceof ezpRouteMethodNotAllowedException )
        {
            $result = new ezpRestMvcResult;
            $result->status = new ezpRestStatusResponse(
                ezpHttpResponseCodes::METHOD_NOT_ALLOWED,
                $this->exception->getMessage(),
                array( 'Allow' => implode( ', ', $this->exception->getAllowedMethods() ) )
            );
            return $result;
        }

        $result = new ezcMvcResult;
        $result->variables['message'] = $this->exception->getMessage();
        $result->status = new ezpRestHttpResponse( ezpHttpResponseCodes::SERVER_ERROR, $this->exception->getMessage() );
        return $result;
    }
1067267
public function getTicketResponse()
    {
        $response = Http::request('GET', static::JSAPI_TICKET)
            ->withAccessToken($this->accessToken)
            ->withQuery(['type' => 'jsapi'])
            ->send();

        if (0 != $response['errcode']) {
            throw new \Exception($response['errmsg'], $response['errcode']);
        }

        return $response;
    }
659807
public function getTicketResponse()
    {
        $response = Http::request('POST', static::TICKET_URL)
            ->withAccessToken($this->accessToken)
            ->withBody($this->getRequestBody())
            ->send();

        if (0 != $response['errcode']) {
            throw new \Exception($response['errmsg'], $response['errcode']);
        }

        return $response;
    }
1229063
public function response()
    {
        return new MultiErrorResponse($this->httpStatusCode, $this->code, $this->message, $this->validationMessages);
    }
686520
public function create(): Response
    {
        $request = $this->request->getPost();

        if (empty($request)) {
            $request = $this->request->getJsonRawBody(true);
        }

        //try to save all the fields we allow
        if ($this->model->save($request, $this->createFields)) {
            return $this->response($this->model->toArray());
        } else {
            //if not thorw exception
            throw new Exception($this->model->getMessages()[0]);
        }
    }
1046762
protected function createResponse()
	{
		try {
			$body = $this->stream->createStream(fopen('php://temp', 'w+b'));
		}
		catch (InvalidArgumentException $e) {
			throw new RuntimeException('Unable to create stream "php://temp"');
		}

		return new ResponseBuilder(
			$this->message->createResponse(200, null, [], $body)
		);
	}
1169454
protected function getErrorResponse()
    {
        if (Request::ajax()) {
            throw new AjaxException('Element not found');
        }

        return Response::make($this->controller->run('404')->getContent(), 404);
    }
550450
public function createDbalException(Response $response, DriverExceptionInterface $exception) {
        switch ($response->getStatusCode()) {
            case Response::HTTP_BAD_REQUEST:
                return new DBALException\SyntaxErrorException($response->getContent(), $exception);

            case Response::HTTP_METHOD_NOT_ALLOWED:
            case Response::HTTP_NOT_ACCEPTABLE:
            case Response::HTTP_REQUEST_TIMEOUT:
            case Response::HTTP_LENGTH_REQUIRED:
            case Response::HTTP_INTERNAL_SERVER_ERROR:
                return new DBALException\ServerException($response->getContent(), $exception);
            
            case Response::HTTP_CONFLICT:
                return new DBALException\ConstraintViolationException($response->getContent(), $exception);

            case Response::HTTP_UNAUTHORIZED:
            case Response::HTTP_FORBIDDEN:
            case Response::HTTP_PROXY_AUTHENTICATION_REQUIRED:
            case Response::HTTP_BAD_GATEWAY:
            case Response::HTTP_SERVICE_UNAVAILABLE:
            case Response::HTTP_GATEWAY_TIMEOUT:
                return new DBALException\ConnectionException($response->getContent(), $exception);

            default:
                return new DBALException\DriverException($response->getContent(), $exception);
        }
    }
1338950
public function httpResponse()
    {
        if ($this->httpResponse === null) {
            throw new RuntimeException(sprintf(
                'PSR-7 HTTP Response is not defined for "%s"',
                get_class($this)
            ));
        }

        return $this->httpResponse;
    }
25104
public function getView(Driver $driver)
    {
        if (!$this->request) {
            throw new RuntimeException('Call "setRequest()" before call this method.');
        }

        $translationDomain = $this->container->getParameter('symfonyid.admin.translation_domain');

        $this->form->handleRequest($this->request);

        $this->view->setParam('form', $this->form->createView());
        $this->view->setParam('menu', $this->container->getParameter('symfonyid.admin.menu.menu_name'));

        $this->view->setParam('errors', false);
        if ($this->request->isMethod('POST')) {
            if (!$this->form->isValid()) {
                $this->view->setParam('errors', true);
                $this->view->setParam('message', $this->translator->trans('message.form_not_valid', array(), $translationDomain));
            } else {
                if ($this->crudOperationHandler->save($driver, $this->form->getData())) {
                    $this->view->setParam('success', $this->translator->trans('message.data_saved', array(), $translationDomain));
                } else {
                    $this->view->setParam('errors', true);
                    $this->view->setParam('message', $this->translator->trans($this->crudOperationHandler->getErrorMessage(), array(), $translationDomain));
                }
            }
        }

        return $this->view;
    }
762994
public function getResponse()
    {
        if (null === ($response = $this->_response)) {
            require_once 'Zend/Amf/Response/Http.php';
            $this->setResponse(new Zend_Amf_Response_Http());
        }
        return $this->_response;
    }
58254
public function getResponse(): ResponseInterface
    {
        if (is_null($this->response)) {
            if (method_exists($this, 'resolve')) {
                $this->setResponse($this->resolve(Response::class)->load());
            } else {
                $response = new Response();
                $this->setResponse($response->load());
            }
        }

        return $this->response;
    }
251874
public function handler(): Response
    {
        $data = $this->validate([
            'name' => [],
            'slug' => [],
            'color' => [],
            'icon' => [],
        ]);
        $role = Role::find($this->getParameter('id'));
        if (!$role) {
            throw new HttpForbiddenException();
        }
        $role->update($data);
        $this->log('info', 'Update role [' . $role->getSlug() . ']');
        return response();
    }
1253107
public function handler(): Response
    {
        $data = $this->validate([
            'role' => []
        ]);
        $member = Member::search($this->getParameter('username'));
        if (!$member) {
            throw new HttpNotFoundException();
        }
        $data['role'] = Role::findBy(['slug' => $data['role']]);
        if (!$data['role']) {
            throw new HttpForbiddenException();
        }
        $member->update($data);
        $this->log('info', 'Update member [' . $member->getUsername() . ']\'s role to [' . $data['role']->getSlug() . ']');
        return response();
    }
1096413
public function getResponse()
	{
		if (method_exists($this->controller, 'getResponse'))
		{
			/** @var HttpResponse $response */
			$response = $this->controller->getResponse();
		}
		else
		{
			$response = new HttpResponse;
		}

		$fp = fopen('php://output', 'w');
		ob_start();
		fputcsv($fp, $this->header, $this->delimiter, $this->enclosure);
		foreach ($this->content as $i => $item)
		{
			try
			{
				$fields = $this->callback ? call_user_func($this->callback, $item) : $item;
				if (!is_array($fields))
				{
					throw new \RuntimeException('CsvExport can only accept arrays, '. gettype($fields) .' provided at index '. $i .'. Either use arrays when setting the records or use a callback to convert each record into an array.');
				}
				fputcsv($fp, $fields, $this->delimiter, $this->enclosure);
			}
			catch (\Exception $ex)
			{
				ob_end_clean();
				throw $ex;
			}
		}
		fclose($fp);
		$response->setContent(ob_get_clean());

		$response->getHeaders()->addHeaders(array(
			'Content-Type' => 'text/csv',
			'Content-Disposition' => 'attachment;filename="'. str_replace('"', '\\"', $this->name) .'.csv"',
		));

		return $response;
	}