Skip to content

Commit e1774b1

Browse files
committed
Throw an exception when attempting to seed from unreadable CSV
1 parent c770b29 commit e1774b1

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/CsvSeeder.php

+4-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@
33
namespace Flynsarmy\CsvSeeder;
44

55
use App;
6-
use Log;
76
use DB;
7+
use Exception;
8+
use Log;
89
use Carbon\Carbon;
910
use Illuminate\Database\Seeder;
1011
use Illuminate\Database\Schema;
@@ -151,14 +152,15 @@ public function openCSV(string $filename)
151152
* @param string $filename
152153
* @param string $deliminator
153154
* @return bool Whether or not the import completed successfully.
155+
* @throws Exception
154156
*/
155157
public function seedFromCSV(string $filename, string $deliminator = ","): bool
156158
{
157159
$handle = $this->openCSV($filename);
158160

159161
// CSV doesn't exist or couldn't be read from.
160162
if ($handle === false) {
161-
return false;
163+
throw new Exception("CSV insert failed: CSV " . $filename . " does not exist or is not readable.");
162164
}
163165

164166
$success = true;

0 commit comments

Comments
 (0)