Attempt to catch DB errors and abort the transaction, so that the queue continues to run.

This commit is contained in:
Deon George 2022-11-12 09:32:39 +11:00
parent e7ebaa85cb
commit 702a4e4f37

View File

@ -343,8 +343,15 @@ class NodelistImport implements ShouldQueue
} }
// Save the system record // Save the system record
try {
$so->save(); $so->save();
} catch (\Exception $e) {
Log::error(sprintf('%s:Error with line [%s] (%s)',self::LOGKEY,$line,$e->getMessage()),['fields'=>$fields]);
DB::rollBack();
throw new \Exception($e->getMessage());
}
// If our zone didnt exist, we'll create it with this system // If our zone didnt exist, we'll create it with this system
if (! $zo->exists) { if (! $zo->exists) {
$zo->system_id = $so->id; $zo->system_id = $so->id;
@ -365,6 +372,8 @@ class NodelistImport implements ShouldQueue
} catch (\Exception $e) { } catch (\Exception $e) {
Log::error(sprintf('%s:Error with line [%s] (%s)',self::LOGKEY,$line,$e->getMessage()),['fields'=>$fields]); Log::error(sprintf('%s:Error with line [%s] (%s)',self::LOGKEY,$line,$e->getMessage()),['fields'=>$fields]);
DB::rollBack();
throw new \Exception($e->getMessage());
} }
if (! ($c % 100)) { if (! ($c % 100)) {