Skip to content

Commit fe7b5e4

Browse files
committed
throwing exception on error instead of logging/warning
1 parent ba7b81a commit fe7b5e4

File tree

1 file changed

+5
-9
lines changed

1 file changed

+5
-9
lines changed

src/Flow/Mongo/MongoFile.php

+5-9
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,8 @@ public function checkChunk()
6969

7070
/**
7171
* Save chunk
72-
*
7372
* @return bool
73+
* @throws \Exception if upload size is invalid or some other unexpected error occurred.
7474
*/
7575
public function saveChunk()
7676
{
@@ -98,15 +98,11 @@ public function saveChunk()
9898

9999
return true;
100100
} catch (\Exception $e) {
101-
trigger_error("Could not store chunk: " . $e->getMessage() . "\n" . $e->getTraceAsString(), E_USER_WARNING);
102-
try {
103-
if (isset($chunkQuery)) {
104-
$this->config->getGridFs()->chunks->remove($chunkQuery);
105-
}
106-
} catch (\Exception $e2) {
107-
// fail gracefully
101+
// try to remove a possibly (partly) stored chunk:
102+
if (isset($chunkQuery)) {
103+
$this->config->getGridFs()->chunks->remove($chunkQuery);
108104
}
109-
return false;
105+
throw $e;
110106
}
111107
}
112108

0 commit comments

Comments
 (0)