mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
Catch "throwable"
This commit is contained in:
parent
6f0ac91bd2
commit
42f39536a1
@ -37,6 +37,8 @@ use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Collection;
|
||||
use Log;
|
||||
use Throwable;
|
||||
|
||||
/**
|
||||
*
|
||||
@ -90,7 +92,6 @@ class ReconcileController extends Controller
|
||||
*
|
||||
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
|
||||
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
|
||||
* @throws \Throwable
|
||||
*/
|
||||
public function overview(Request $request, Account $account, Carbon $start, Carbon $end): JsonResponse
|
||||
{
|
||||
@ -123,15 +124,24 @@ class ReconcileController extends Controller
|
||||
}
|
||||
$difference = bcadd(bcadd(bcsub($startBalance, $endBalance), $clearedAmount), $amount);
|
||||
$diffCompare = bccomp($difference, '0');
|
||||
$return = [
|
||||
'post_uri' => $route,
|
||||
'html' => view(
|
||||
|
||||
try {
|
||||
$view = view(
|
||||
'accounts.reconcile.overview', compact(
|
||||
'account', 'start', 'diffCompare', 'difference', 'end', 'clearedIds', 'transactionIds', 'clearedAmount',
|
||||
'startBalance', 'endBalance', 'amount',
|
||||
'route', 'countCleared'
|
||||
)
|
||||
)->render(),
|
||||
)->render();
|
||||
} catch (Throwable $e) {
|
||||
Log::debug(sprintf('View error: %s', $e->getMessage()));
|
||||
$view = 'Could not render accounts.reconcile.overview';
|
||||
}
|
||||
|
||||
|
||||
$return = [
|
||||
'post_uri' => $route,
|
||||
'html' => $view,
|
||||
];
|
||||
|
||||
return response()->json($return);
|
||||
@ -148,7 +158,6 @@ class ReconcileController extends Controller
|
||||
* @return mixed
|
||||
*
|
||||
* @throws FireflyException
|
||||
* @throws \Throwable
|
||||
*/
|
||||
public function transactions(Account $account, Carbon $start, Carbon $end)
|
||||
{
|
||||
@ -180,9 +189,14 @@ class ReconcileController extends Controller
|
||||
$collector->setAccounts(new Collection([$account]))
|
||||
->setRange($selectionStart, $selectionEnd)->withBudgetInformation()->withOpposingAccount()->withCategoryInformation();
|
||||
$transactions = $collector->getJournals();
|
||||
$html = view(
|
||||
'accounts.reconcile.transactions', compact('account', 'transactions', 'currency', 'start', 'end', 'selectionStart', 'selectionEnd')
|
||||
)->render();
|
||||
try {
|
||||
$html = view(
|
||||
'accounts.reconcile.transactions', compact('account', 'transactions', 'currency', 'start', 'end', 'selectionStart', 'selectionEnd')
|
||||
)->render();
|
||||
} catch (Throwable $e) {
|
||||
Log::debug(sprintf('Could not render: %s', $e->getMessage()));
|
||||
$html = 'Could not render accounts.reconcile.transactions';
|
||||
}
|
||||
|
||||
return response()->json(['html' => $html, 'startBalance' => $startBalance, 'endBalance' => $endBalance]);
|
||||
}
|
||||
|
@ -27,6 +27,8 @@ use FireflyIII\Http\Controllers\Controller;
|
||||
use FireflyIII\Repositories\Account\AccountTaskerInterface;
|
||||
use FireflyIII\Support\CacheProperties;
|
||||
use Illuminate\Support\Collection;
|
||||
use Log;
|
||||
use Throwable;
|
||||
|
||||
/**
|
||||
* Class AccountController.
|
||||
@ -43,7 +45,6 @@ class AccountController extends Controller
|
||||
*
|
||||
* @return mixed|string
|
||||
*
|
||||
* @throws \Throwable
|
||||
*/
|
||||
public function general(Collection $accounts, Carbon $start, Carbon $end)
|
||||
{
|
||||
@ -60,8 +61,12 @@ class AccountController extends Controller
|
||||
/** @var AccountTaskerInterface $accountTasker */
|
||||
$accountTasker = app(AccountTaskerInterface::class);
|
||||
$accountReport = $accountTasker->getAccountReport($accounts, $start, $end);
|
||||
|
||||
$result = view('reports.partials.accounts', compact('accountReport'))->render();
|
||||
try {
|
||||
$result = view('reports.partials.accounts', compact('accountReport'))->render();
|
||||
} catch (Throwable $e) {
|
||||
Log::debug(sprintf('Could not render reports.partials.accounts: %s', $e->getMessage()));
|
||||
$result = 'Could not render view.';
|
||||
}
|
||||
$cache->store($result);
|
||||
|
||||
return $result;
|
||||
|
@ -27,6 +27,8 @@ use FireflyIII\Helpers\Report\BalanceReportHelperInterface;
|
||||
use FireflyIII\Http\Controllers\Controller;
|
||||
use FireflyIII\Support\CacheProperties;
|
||||
use Illuminate\Support\Collection;
|
||||
use Log;
|
||||
use Throwable;
|
||||
|
||||
/**
|
||||
* Class BalanceController.
|
||||
@ -42,7 +44,6 @@ class BalanceController extends Controller
|
||||
* @param Carbon $end
|
||||
*
|
||||
* @return mixed|string
|
||||
* @throws \Throwable
|
||||
*/
|
||||
public function general(Collection $accounts, Carbon $start, Carbon $end)
|
||||
{
|
||||
@ -58,8 +59,12 @@ class BalanceController extends Controller
|
||||
}
|
||||
$helper = app(BalanceReportHelperInterface::class);
|
||||
$balance = $helper->getBalanceReport($accounts, $start, $end);
|
||||
|
||||
$result = view('reports.partials.balance', compact('balance'))->render();
|
||||
try {
|
||||
$result = view('reports.partials.balance', compact('balance'))->render();
|
||||
} catch (Throwable $e) {
|
||||
Log::debug(sprintf('Could not render reports.partials.balance: %s', $e->getMessage()));
|
||||
$result = 'Could not render view.';
|
||||
}
|
||||
$cache->store($result);
|
||||
|
||||
return $result;
|
||||
|
@ -28,6 +28,8 @@ use FireflyIII\Http\Controllers\Controller;
|
||||
use FireflyIII\Repositories\Budget\BudgetRepositoryInterface;
|
||||
use FireflyIII\Support\CacheProperties;
|
||||
use Illuminate\Support\Collection;
|
||||
use Log;
|
||||
use Throwable;
|
||||
|
||||
/**
|
||||
* Class BudgetController.
|
||||
@ -43,7 +45,6 @@ class BudgetController extends Controller
|
||||
* @param Carbon $end
|
||||
*
|
||||
* @return mixed|string
|
||||
* @throws \Throwable
|
||||
*/
|
||||
public function general(Collection $accounts, Carbon $start, Carbon $end)
|
||||
{
|
||||
@ -58,8 +59,12 @@ class BudgetController extends Controller
|
||||
}
|
||||
$helper = app(BudgetReportHelperInterface::class);
|
||||
$budgets = $helper->getBudgetReport($start, $end, $accounts);
|
||||
|
||||
$result = view('reports.partials.budgets', compact('budgets'))->render();
|
||||
try {
|
||||
$result = view('reports.partials.budgets', compact('budgets'))->render();
|
||||
} catch (Throwable $e) {
|
||||
Log::debug(sprintf('Could not render reports.partials.budgets: %s', $e->getMessage()));
|
||||
$result = 'Could not render view.';
|
||||
}
|
||||
$cache->store($result);
|
||||
|
||||
return $result;
|
||||
@ -74,7 +79,6 @@ class BudgetController extends Controller
|
||||
* @param Carbon $end
|
||||
*
|
||||
* @return mixed|string
|
||||
* @throws \Throwable
|
||||
*/
|
||||
public function period(Collection $accounts, Carbon $start, Carbon $end)
|
||||
{
|
||||
@ -95,8 +99,12 @@ class BudgetController extends Controller
|
||||
$data[0] = $repository->getNoBudgetPeriodReport($accounts, $start, $end); // append report data for "no budget"
|
||||
$report = $this->filterBudgetPeriodReport($data);
|
||||
$periods = app('navigation')->listOfPeriods($start, $end);
|
||||
|
||||
$result = view('reports.partials.budget-period', compact('report', 'periods'))->render();
|
||||
try {
|
||||
$result = view('reports.partials.budget-period', compact('report', 'periods'))->render();
|
||||
} catch (Throwable $e) {
|
||||
Log::debug(sprintf('Could not render reports.partials.budget-period: %s', $e->getMessage()));
|
||||
$result = 'Could not render view.';
|
||||
}
|
||||
$cache->store($result);
|
||||
|
||||
return $result;
|
||||
|
@ -27,6 +27,8 @@ use FireflyIII\Http\Controllers\Controller;
|
||||
use FireflyIII\Repositories\Account\AccountTaskerInterface;
|
||||
use FireflyIII\Support\CacheProperties;
|
||||
use Illuminate\Support\Collection;
|
||||
use Log;
|
||||
use Throwable;
|
||||
|
||||
/**
|
||||
* Class OperationsController.
|
||||
@ -63,7 +65,6 @@ class OperationsController extends Controller
|
||||
* @param Carbon $end
|
||||
*
|
||||
* @return mixed|string
|
||||
* @throws \Throwable
|
||||
*/
|
||||
public function expenses(Collection $accounts, Carbon $start, Carbon $end)
|
||||
{
|
||||
@ -78,7 +79,12 @@ class OperationsController extends Controller
|
||||
}
|
||||
$entries = $this->tasker->getExpenseReport($start, $end, $accounts);
|
||||
$type = 'expense-entry';
|
||||
$result = view('reports.partials.income-expenses', compact('entries', 'type'))->render();
|
||||
try {
|
||||
$result = view('reports.partials.income-expenses', compact('entries', 'type'))->render();
|
||||
} catch (Throwable $e) {
|
||||
Log::debug(sprintf('Could not render reports.partials.income-expense: %s', $e->getMessage()));
|
||||
$result = 'Could not render view.';
|
||||
}
|
||||
$cache->store($result);
|
||||
|
||||
return $result;
|
||||
@ -92,7 +98,6 @@ class OperationsController extends Controller
|
||||
* @param Carbon $end
|
||||
*
|
||||
* @return string
|
||||
* @throws \Throwable
|
||||
*/
|
||||
public function income(Collection $accounts, Carbon $start, Carbon $end): string
|
||||
{
|
||||
@ -107,7 +112,12 @@ class OperationsController extends Controller
|
||||
}
|
||||
$entries = $this->tasker->getIncomeReport($start, $end, $accounts);
|
||||
$type = 'income-entry';
|
||||
try {
|
||||
$result = view('reports.partials.income-expenses', compact('entries', 'type'))->render();
|
||||
} catch (Throwable $e) {
|
||||
Log::debug(sprintf('Could not render reports.partials.income-expenses: %s', $e->getMessage()));
|
||||
$result = 'Could not render view.';
|
||||
}
|
||||
|
||||
$cache->store($result);
|
||||
|
||||
@ -122,7 +132,6 @@ class OperationsController extends Controller
|
||||
* @param Carbon $end
|
||||
*
|
||||
* @return mixed|string
|
||||
* @throws \Throwable
|
||||
*/
|
||||
public function operations(Collection $accounts, Carbon $start, Carbon $end)
|
||||
{
|
||||
@ -155,8 +164,12 @@ class OperationsController extends Controller
|
||||
$expenses
|
||||
)
|
||||
);
|
||||
|
||||
try {
|
||||
$result = view('reports.partials.operations', compact('incomeSum', 'expensesSum'))->render();
|
||||
} catch (Throwable $e) {
|
||||
Log::debug(sprintf('Could not render reports.partials.operations: %s', $e->getMessage()));
|
||||
$result = 'Could not render view.';
|
||||
}
|
||||
$cache->store($result);
|
||||
|
||||
return $result;
|
||||
|
Loading…
Reference in New Issue
Block a user