Don't throw error, report it.

This commit is contained in:
James Cole
2025-11-04 20:48:58 +01:00
parent a3eb3bb1a4
commit 0bc2d40d9b
7 changed files with 61 additions and 18 deletions

View File

@@ -95,7 +95,7 @@ class AttachmentController extends Controller
/**
* Download attachment to PC.
*
* @return LaravelResponse
* @return LaravelResponse|View
*
* @throws FireflyException
*/
@@ -121,8 +121,8 @@ class AttachmentController extends Controller
return $response;
}
throw new FireflyException('Could not find the indicated attachment. The file is no longer there.');
$message = 'Could not find the indicated attachment. The file is no longer there.';
return view('errors.error', compact('message'));
}
/**
@@ -194,7 +194,7 @@ class AttachmentController extends Controller
*
* @throws FireflyException
*/
public function view(Attachment $attachment): LaravelResponse
public function view(Attachment $attachment): LaravelResponse|View
{
if ($this->repository->exists($attachment)) {
$content = $this->repository->getContent($attachment);
@@ -223,6 +223,7 @@ class AttachmentController extends Controller
);
}
throw new FireflyException('Could not find the indicated attachment. The file is no longer there.');
$message = 'Could not find the indicated attachment. The file is no longer there.';
return view('errors.error', compact('message'));
}
}

View File

@@ -73,7 +73,7 @@ class ForgotPasswordController extends Controller
$message = sprintf('Cannot reset password when authenticating over "%s".', config('firefly.authentication_guard'));
Log::error($message);
return view('error', compact('message'));
return view('errors.error', compact('message'));
}
// validate host header.
@@ -138,7 +138,7 @@ class ForgotPasswordController extends Controller
if ('web' !== config('firefly.authentication_guard')) {
$message = sprintf('Cannot reset password when authenticating over "%s".', config('firefly.authentication_guard'));
return view('error', compact('message'));
return view('errors.error', compact('message'));
}
// is allowed to?

View File

@@ -158,12 +158,12 @@ class RegisterController extends Controller
if (true === $allowRegistration) {
$message = 'You do not need an invite code on this installation.';
return view('error', compact('message'));
return view('errors.error', compact('message'));
}
if (false === $validCode) {
$message = 'Invalid code.';
return view('error', compact('message'));
return view('errors.error', compact('message'));
}
$email = $request->old('email');
@@ -189,7 +189,7 @@ class RegisterController extends Controller
if (false === $allowRegistration) {
$message = 'Registration is currently not available. If you are the administrator, you can enable this in the administration.';
return view('error', compact('message'));
return view('errors.error', compact('message'));
}
$email = $request?->old('email');

View File

@@ -80,7 +80,7 @@ class ResetPasswordController extends Controller
if ('web' !== config('firefly.authentication_guard')) {
$message = sprintf('Cannot reset password when authenticating over "%s".', config('firefly.authentication_guard'));
return view('error', compact('message'));
return view('errors.error', compact('message'));
}
$rules = [
@@ -127,7 +127,7 @@ class ResetPasswordController extends Controller
if ('web' !== config('firefly.authentication_guard')) {
$message = sprintf('Cannot reset password when authenticating over "%s".', config('firefly.authentication_guard'));
return view('error', compact('message'));
return view('errors.error', compact('message'));
}
// is allowed to register?

View File

@@ -82,7 +82,7 @@ class ReportController extends Controller
public function auditReport(Collection $accounts, Carbon $start, Carbon $end)
{
if ($end < $start) {
return view('error')->with('message', (string) trans('firefly.end_after_start_date'));
return view('errors.error')->with('message', (string) trans('firefly.end_after_start_date'));
}
$this->repository->cleanupBudgets();
$start->endOfDay(); // end of day so the final balance is at the end of that day.
@@ -115,7 +115,7 @@ class ReportController extends Controller
public function budgetReport(Collection $accounts, Collection $budgets, Carbon $start, Carbon $end)
{
if ($end < $start) {
return view('error')->with('message', (string) trans('firefly.end_after_start_date'));
return view('errors.error')->with('message', (string) trans('firefly.end_after_start_date'));
}
$this->repository->cleanupBudgets();
$start->endOfDay(); // end of day so the final balance is at the end of that day.
@@ -149,7 +149,7 @@ class ReportController extends Controller
public function categoryReport(Collection $accounts, Collection $categories, Carbon $start, Carbon $end)
{
if ($end < $start) {
return view('error')->with('message', (string) trans('firefly.end_after_start_date'));
return view('errors.error')->with('message', (string) trans('firefly.end_after_start_date'));
}
$this->repository->cleanupBudgets();
$start->endOfDay(); // end of day so the final balance is at the end of that day.
@@ -183,7 +183,7 @@ class ReportController extends Controller
public function defaultReport(Collection $accounts, Carbon $start, Carbon $end)
{
if ($end < $start) {
return view('error')->with('message', (string) trans('firefly.end_after_start_date'));
return view('errors.error')->with('message', (string) trans('firefly.end_after_start_date'));
}
$this->repository->cleanupBudgets();
@@ -336,7 +336,7 @@ class ReportController extends Controller
}
if ($request->getEndDate() < $request->getStartDate()) {
return view('error')->with('message', (string) trans('firefly.end_after_start_date'));
return view('errors.error')->with('message', (string) trans('firefly.end_after_start_date'));
}
$url = match ($reportType) {
@@ -361,7 +361,7 @@ class ReportController extends Controller
public function tagReport(Collection $accounts, Collection $tags, Carbon $start, Carbon $end)
{
if ($end < $start) {
return view('error')->with('message', (string) trans('firefly.end_after_start_date'));
return view('errors.error')->with('message', (string) trans('firefly.end_after_start_date'));
}
$this->repository->cleanupBudgets();
$start->endOfDay(); // end of day so the final balance is at the end of that day.