Catch "throwable"

This commit is contained in:
James Cole
2018-08-07 19:29:40 +02:00
parent 6f0ac91bd2
commit 42f39536a1
5 changed files with 71 additions and 26 deletions

View File

@@ -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;