DXCMS-57: Work-around for misbehaving fopen().

In some cases, an fopen() of a URL will not result in an error
messsage, but in a silent failure. Thus, instead of having a
silent failure produce a plain Exception, we now have it
generating a FileNotFoundException.
This commit is contained in:
Technosophos 2012-08-06 17:43:36 -05:00
parent 87794f697e
commit febebd4b94
2 changed files with 13 additions and 1 deletions

View File

@ -75,7 +75,11 @@ class PHPStreamTransport implements Transporter {
$err = error_get_last();
if (empty($err['message'])) {
throw new \HPCloud\Exception("An unknown exception occurred while sending a request.");
// FIXME: Under certain circumstances, all this really means is that
// there is a 404. So we pretend that it's always a 404.
// throw new \HPCloud\Exception("An unknown exception occurred while sending a request.");
$msg = "File not found, perhaps due to a network failure.";
throw new \HPCloud\Transport\FileNotFoundException($msg);
}
$this->guessError($err['message'], $uri, $method);

View File

@ -190,6 +190,14 @@ class ContainerTest extends \HPCloud\Tests\TestCase {
// Overwrite the copy:
$object->setContent('HI');
$this->assertEquals('HI', $object->content());
// Make sure this throws a 404.
try {
$foo = $container->object('no/such');
}
catch (\HPCloud\Exception $e) {
$this->assertInstanceOf('\HPCloud\Transport\FileNotFoundException', $e);
}
}
/**