Skip to content

Commit 87a0eb5

Browse files
committed
Remove catching exception
1 parent 4872bae commit 87a0eb5

File tree

2 files changed

+10
-18
lines changed

2 files changed

+10
-18
lines changed

lib/OpenCloud/ObjectStore/Resource/Container.php

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -239,22 +239,13 @@ public function deleteAllObjects()
239239
* Delete an object from the API.
240240
*
241241
* @param string $name The name of object you want to delete
242-
* @return True if object was delete with success. False if an error occurred
243-
* @throws ObjectNotFoundException When the file you want to delete is not found
242+
* @throws \Guzzle\Http\Exception\BadResponseException When an error occurred
244243
*/
245244
public function deleteObject($name)
246245
{
247-
try {
248-
$response = $this->getClient()
249-
->delete($this->getUrl($name))
250-
->send();
251-
return ($response->getStatusCode() == 204);
252-
} catch (BadResponseException $e) {
253-
if ($e->getResponse()->getStatusCode() == 404) {
254-
throw ObjectNotFoundException::factory($name, $e);
255-
}
256-
}
257-
return false;
246+
$response = $this->getClient()
247+
->delete($this->getUrl($name))
248+
->send();
258249
}
259250

260251
/**

tests/OpenCloud/Tests/ObjectStore/Resource/ContainerTest.php

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -122,20 +122,21 @@ public function test_Delete_Object()
122122
{
123123
$container = $this->container;
124124
$this->addMockSubscriber($this->makeResponse('[]', 204));
125-
$response = $container->deleteObject("someObject");
126-
$this->assertTrue($response);
125+
$container->deleteObject("someObject");
127126
}
128127

128+
/**
129+
* @expectedException \Guzzle\Http\Exception\BadResponseException
130+
*/
129131
public function test_Delete_Object_With_Failure()
130132
{
131133
$container = $this->container;
132134
$this->addMockSubscriber($this->makeResponse('[]', 500));
133-
$response = $container->deleteObject("someObject");
134-
$this->assertFalse($response);
135+
$container->deleteObject("someObject");
135136
}
136137

137138
/**
138-
* @expectedException \OpenCloud\ObjectStore\Exception\ObjectNotFoundException
139+
* @expectedException \Guzzle\Http\Exception\BadResponseException
139140
*/
140141
public function test_Delete_NonExisting_Object()
141142
{

0 commit comments

Comments
 (0)