getStatusCode(), $previous); $this->response = $response; } /** * Return a new exception instance with an updated response. * * @param \Throwable|null $previous Previous exception, or the current * previous exception when omitted. * * @return static */ public function withResponse( #[\SensitiveParameter] ResponseInterface $response, #[\SensitiveParameter] ?\Throwable $previous = null ): self { if ($response->getStatusCode() !== $this->response->getStatusCode()) { throw new InvalidArgumentException('Cannot replace response with a different status code.'); } return new static( $this->getMessage(), $this->getRequest(), $response, $previous ?? $this->getPrevious() ); } /** * Get the associated response. */ public function getResponse(): ResponseInterface { return $this->response; } }