Firefly III: a personal finances manager
PHP accountingbudgetbudgetingbudgetscash-flowcashflowcredit-carddockerexpensesfinancefinancesfinanciallinuxmoneypaycheckpersonal-financephpphp7
Catch some exceptions.
James Cole99651bb61e4c
diff --git a/app/Jobs/MailError.php b/app/Jobs/MailError.phpindex ecc8c24b5d..b6f3c62416 100644--- a/app/Jobs/MailError.php+++ b/app/Jobs/MailError.php@@ -31,6 +31,8 @@ use Illuminate\Queue\InteractsWithQueue;use Illuminate\Queue\SerializesModels;use Illuminate\Support\Facades\Log;use Illuminate\Support\Facades\Mail;+use Safe\Exceptions\FilesystemException;+use Safe\Exceptions\JsonException;use Symfony\Component\Mailer\Exception\TransportException;use function Safe\file_get_contents;@@ -125,11 +127,23 @@ class MailError extends Job implements ShouldQueueif (!file_exists($file)) {Log::debug(sprintf('Wrote new file in "%s"', $file));- file_put_contents($file, json_encode($limits, JSON_PRETTY_PRINT));+ try {+ file_put_contents($file, json_encode($limits, JSON_PRETTY_PRINT));+ } catch (FilesystemException $e) {+ Log::warning(sprintf('[a] Could not write file "%s": %s', $file, $e->getMessage()));+ } catch (JsonException $e) {+ Log::warning(sprintf('[b] Could not parse file "%s": %s', $file, $e->getMessage()));+ }}if (file_exists($file)) {Log::debug(sprintf('Read file in "%s"', $file));- $limits = json_decode(file_get_contents($file), true);+ try {+ $limits = json_decode(file_get_contents($file), true);+ } catch (FilesystemException $e) {+ Log::warning(sprintf('[c] Could not read file "%s": %s', $file, $e->getMessage()));+ } catch (JsonException $e) {+ Log::warning(sprintf('[d] Could not parse file "%s": %s', $file, $e->getMessage()));+ }}// limit reached?foreach ($types as $type => $info) {@@ -157,7 +171,13 @@ class MailError extends Job implements ShouldQueue}++$limits[$type]['sent'];}- file_put_contents($file, json_encode($limits, JSON_PRETTY_PRINT));+ try {+ file_put_contents($file, json_encode($limits, JSON_PRETTY_PRINT));+ } catch (FilesystemException $e) {+ Log::warning(sprintf('[c] Could not write file "%s": %s', $file, $e->getMessage()));+ } catch (JsonException $e) {+ Log::warning(sprintf('[c] Could not parse file "%s": %s', $file, $e->getMessage()));+ }Log::debug('No limits reached, return FALSE.');return false;