Update error catch

This commit is contained in:
James Cole
2022-11-01 19:24:34 +01:00
parent e7e3370baa
commit ebcf9b3be1
5 changed files with 10 additions and 6 deletions

View File

@@ -28,6 +28,7 @@ use Exception;
use FireflyIII\Models\Transaction;
use FireflyIII\Models\TransactionJournal;
use Illuminate\Console\Command;
use Illuminate\Database\QueryException;
use Log;
/**
@@ -77,7 +78,7 @@ class DeleteEmptyJournals extends Command
// uneven number, delete journal and transactions:
try {
TransactionJournal::find((int)$row->transaction_journal_id)->delete();
} catch (Exception $e) {
} catch (QueryException $e) {
Log::info(sprintf('Could not delete journal: %s', $e->getMessage()));
}
@@ -104,7 +105,7 @@ class DeleteEmptyJournals extends Command
foreach ($set as $entry) {
try {
TransactionJournal::find($entry->id)->delete();
} catch (Exception $e) {
} catch (QueryException $e) {
Log::info(sprintf('Could not delete entry: %s', $e->getMessage()));
}

View File

@@ -27,6 +27,7 @@ use Exception;
use FireflyIII\Models\Transaction;
use FireflyIII\Models\TransactionJournal;
use Illuminate\Console\Command;
use Illuminate\Database\QueryException;
use Log;
use stdClass;
@@ -147,7 +148,7 @@ class DeleteOrphanedTransactions extends Command
if ($journal) {
try {
$journal->delete();
} catch (Exception $e) {
} catch (QueryException $e) {
Log::info(sprintf('Could not delete journal %s', $e->getMessage()));
}
}

View File

@@ -27,6 +27,7 @@ use Exception;
use FireflyIII\Models\Transaction;
use FireflyIII\Models\TransactionJournal;
use Illuminate\Console\Command;
use Illuminate\Database\QueryException;
/**
* Class DeleteZeroAmount
@@ -62,7 +63,7 @@ class DeleteZeroAmount extends Command
$this->info(sprintf('Deleted transaction journal #%d because the amount is zero (0.00).', $journal->id));
try {
$journal->delete();
} catch (Exception $e) {
} catch (QueryException $e) {
$this->line($e->getMessage());
}

View File

@@ -229,7 +229,7 @@ class BackToJournals extends Command
foreach ($chunks as $chunk) {
$set = DB::table('transactions')
->whereIn('transactions.id', $chunk)
->get(['transaction_journal_id'])->pluck('transaction_journal_id')->toArray();
->pluck('transaction_journal_id')->toArray();
$array = array_merge($array, $set);
}

View File

@@ -28,6 +28,7 @@ use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Models\Note;
use FireflyIII\Models\TransactionJournalMeta;
use Illuminate\Console\Command;
use Illuminate\Database\QueryException;
use Log;
use Psr\Container\ContainerExceptionInterface;
use Psr\Container\NotFoundExceptionInterface;
@@ -83,7 +84,7 @@ class MigrateJournalNotes extends Command
Log::debug(sprintf('Migrated meta note #%d to Note #%d', $meta->id, $note->id));
try {
$meta->delete();
} catch (Exception $e) {
} catch (QueryException $e) {
Log::error(sprintf('Could not delete old meta entry #%d: %s', $meta->id, $e->getMessage()));
}