Commit ddd5bbfb authored by maacl's avatar maacl Committed by heddn

Issue #3076365 by k_a_l, maacl, heddn: A more graceful failure for a missing CSV source file?

parent 225f26e4
......@@ -259,7 +259,14 @@ class CSV extends SourcePluginBase implements ConfigurableInterface {
* The reader.
*/
protected function createReader() {
return Reader::createFromStream(fopen($this->configuration['path'], 'r'));
if (!file_exists($this->configuration['path'])) {
throw new \RuntimeException(sprintf('File "%s" was not found.', $this->configuration['path']));
}
$csv = fopen($this->configuration['path'], 'r');
if (!$csv) {
throw new \RuntimeException(sprintf('File "%s" could not be opened.', $this->configuration['path']));
}
return Reader::createFromStream($csv);
}
}
......@@ -359,8 +359,8 @@ EOD;
];
$csv = new CSV($configuration, $this->pluginId, $this->pluginDefinition, $this->migration);
$this->expectException(Warning::class);
$this->expectExceptionMessage('fopen(non-existent-path): failed to open stream: No such file or directory');
$this->expectException(\RuntimeException::class);
$this->expectExceptionMessage('File "non-existent-path" was not found.');
$csv->initializeIterator();
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment