mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-09-05 04:03:26 +00:00
Remove static references
This commit is contained in:
@@ -83,41 +83,41 @@ class Handler extends ExceptionHandler
|
||||
$expectsJson = $request->expectsJson();
|
||||
// if the user requests anything /api/, assume the user wants to see JSON.
|
||||
if (str_starts_with($request->getRequestUri(), '/api/')) {
|
||||
Log::debug('API endpoint, always assume user wants JSON.');
|
||||
app('log')->debug('API endpoint, always assume user wants JSON.');
|
||||
$expectsJson = true;
|
||||
}
|
||||
|
||||
Log::debug('Now in Handler::render()');
|
||||
app('log')->debug('Now in Handler::render()');
|
||||
if ($e instanceof LaravelValidationException && $expectsJson) {
|
||||
// ignore it: controller will handle it.
|
||||
Log::debug(sprintf('Return to parent to handle LaravelValidationException(%d)', $e->status));
|
||||
app('log')->debug(sprintf('Return to parent to handle LaravelValidationException(%d)', $e->status));
|
||||
return parent::render($request, $e);
|
||||
}
|
||||
if ($e instanceof NotFoundHttpException && $expectsJson) {
|
||||
// JSON error:
|
||||
Log::debug('Return JSON not found error.');
|
||||
app('log')->debug('Return JSON not found error.');
|
||||
return response()->json(['message' => 'Resource not found', 'exception' => 'NotFoundHttpException'], 404);
|
||||
}
|
||||
|
||||
if ($e instanceof AuthenticationException && $expectsJson) {
|
||||
// somehow Laravel handler does not catch this:
|
||||
Log::debug('Return JSON unauthenticated error.');
|
||||
app('log')->debug('Return JSON unauthenticated error.');
|
||||
return response()->json(['message' => 'Unauthenticated', 'exception' => 'AuthenticationException'], 401);
|
||||
}
|
||||
|
||||
if ($e instanceof OAuthServerException && $expectsJson) {
|
||||
Log::debug('Return JSON OAuthServerException.');
|
||||
app('log')->debug('Return JSON OAuthServerException.');
|
||||
// somehow Laravel handler does not catch this:
|
||||
return response()->json(['message' => $e->getMessage(), 'exception' => 'OAuthServerException'], 401);
|
||||
}
|
||||
if ($e instanceof BadRequestHttpException) {
|
||||
Log::debug('Return JSON BadRequestHttpException.');
|
||||
app('log')->debug('Return JSON BadRequestHttpException.');
|
||||
return response()->json(['message' => $e->getMessage(), 'exception' => 'BadRequestHttpException'], 400);
|
||||
}
|
||||
|
||||
if ($e instanceof BadHttpHeaderException) {
|
||||
// is always API exception.
|
||||
Log::debug('Return JSON BadHttpHeaderException.');
|
||||
app('log')->debug('Return JSON BadHttpHeaderException.');
|
||||
return response()->json(['message' => $e->getMessage(), 'exception' => 'BadHttpHeaderException'], $e->statusCode);
|
||||
}
|
||||
|
||||
@@ -127,7 +127,7 @@ class Handler extends ExceptionHandler
|
||||
|
||||
$isDebug = config('app.debug', false);
|
||||
if ($isDebug) {
|
||||
Log::debug(sprintf('Return JSON %s with debug.', get_class($e)));
|
||||
app('log')->debug(sprintf('Return JSON %s with debug.', get_class($e)));
|
||||
return response()->json(
|
||||
[
|
||||
'message' => $e->getMessage(),
|
||||
@@ -139,7 +139,7 @@ class Handler extends ExceptionHandler
|
||||
$errorCode
|
||||
);
|
||||
}
|
||||
Log::debug(sprintf('Return JSON %s.', get_class($e)));
|
||||
app('log')->debug(sprintf('Return JSON %s.', get_class($e)));
|
||||
return response()->json(
|
||||
['message' => sprintf('Internal Firefly III Exception: %s', $e->getMessage()), 'exception' => get_class($e)],
|
||||
$errorCode
|
||||
@@ -147,7 +147,7 @@ class Handler extends ExceptionHandler
|
||||
}
|
||||
|
||||
if ($e instanceof NotFoundHttpException) {
|
||||
Log::debug('Refer to GracefulNotFoundHandler');
|
||||
app('log')->debug('Refer to GracefulNotFoundHandler');
|
||||
$handler = app(GracefulNotFoundHandler::class);
|
||||
|
||||
return $handler->render($request, $e);
|
||||
@@ -155,20 +155,20 @@ class Handler extends ExceptionHandler
|
||||
|
||||
// special view for database errors with extra instructions
|
||||
if ($e instanceof QueryException) {
|
||||
Log::debug('Return Firefly III database exception view.');
|
||||
app('log')->debug('Return Firefly III database exception view.');
|
||||
$isDebug = config('app.debug');
|
||||
|
||||
return response()->view('errors.DatabaseException', ['exception' => $e, 'debug' => $isDebug], 500);
|
||||
}
|
||||
|
||||
if ($e instanceof FireflyException || $e instanceof ErrorException || $e instanceof OAuthServerException) {
|
||||
Log::debug('Return Firefly III error view.');
|
||||
app('log')->debug('Return Firefly III error view.');
|
||||
$isDebug = config('app.debug');
|
||||
|
||||
return response()->view('errors.FireflyException', ['exception' => $e, 'debug' => $isDebug], 500);
|
||||
}
|
||||
|
||||
Log::debug(sprintf('Error "%s" has no Firefly III treatment, parent will handle.', get_class($e)));
|
||||
app('log')->debug(sprintf('Error "%s" has no Firefly III treatment, parent will handle.', get_class($e)));
|
||||
|
||||
return parent::render($request, $e);
|
||||
}
|
||||
|
Reference in New Issue
Block a user