php-http/HttplugBundle

Undefined method getResponse() being called on RequestExceptionInterface

Csabi opened this issue · 1 comments

Csabi commented
Q A
Bug? yes
New Feature? no
Version 1.14.0

There are several instances of undefined method getResponse() being called on Psr\Http\Client\RequestExceptionInterface

Http\HttplugBundle\Collector\Formatter::formatException()

if ($exception instanceof HttpException || $exception instanceof RequestExceptionInterface) {
    return $this->formatter->formatResponse($exception->getResponse());

Http\HttplugBundle\Collector\ProfileClient::collectExceptionInformations()

if ($exception instanceof HttpException || $exception instanceof RequestExceptionInterface) {
    $this->collectResponseInformations($exception->getResponse(), $event, $stack);
dbu commented

that sounds indeed wrong. when we have an exception that can provide a response, we should use it, but the idea of those checks is to only request it if it is available. can you do a pull request that limits the ->getResponse to those exceptions that actually have that method?