/** * Handles a bad response when attempting to revalidate * * @param BadResponseException $e Exception encountered * * @throws BadResponseException */ protected function handleBadResponse(BadResponseException $e) { // 404 errors mean the resource no longer exists, so remove from // cache, and prevent an additional request by throwing the exception if ($e->getResponse()->getStatusCode() == 404) { $this->storage->delete($e->getRequest()); throw $e; } }
/** * Default method that will throw exceptions if an unsuccessful response is received. * * @param Event $event Received * @throws BadResponseException if the response is not successful */ public static function onRequestError(Event $event) { $e = BadResponseException::factory($event['request'], $event['response']); $event['request']->setState(self::STATE_ERROR, array('exception' => $e) + $event->toArray()); throw $e; }