File tree 1 file changed +4
-2
lines changed
1 file changed +4
-2
lines changed Original file line number Diff line number Diff line change 3
3
namespace Flynsarmy \CsvSeeder ;
4
4
5
5
use App ;
6
- use Log ;
7
6
use DB ;
7
+ use Exception ;
8
+ use Log ;
8
9
use Carbon \Carbon ;
9
10
use Illuminate \Database \Seeder ;
10
11
use Illuminate \Database \Schema ;
@@ -151,14 +152,15 @@ public function openCSV(string $filename)
151
152
* @param string $filename
152
153
* @param string $deliminator
153
154
* @return bool Whether or not the import completed successfully.
155
+ * @throws Exception
154
156
*/
155
157
public function seedFromCSV (string $ filename , string $ deliminator = ", " ): bool
156
158
{
157
159
$ handle = $ this ->openCSV ($ filename );
158
160
159
161
// CSV doesn't exist or couldn't be read from.
160
162
if ($ handle === false ) {
161
- return false ;
163
+ throw new Exception ( " CSV insert failed: CSV " . $ filename . " does not exist or is not readable. " ) ;
162
164
}
163
165
164
166
$ success = true ;
You can’t perform that action at this time.
0 commit comments