Expand exception code and fix demo user redirect.

This commit is contained in:
James Cole
2018-03-07 05:51:51 +01:00
parent f349aa47ce
commit d52d8d7970
10 changed files with 22 additions and 22 deletions

View File

@@ -22,9 +22,10 @@ declare(strict_types=1);
namespace FireflyIII\Exceptions;
use Exception;
/**
* Class FireflyException.
*/
class FireflyException extends \Exception
class FireflyException extends Exception
{
}

View File

@@ -70,14 +70,15 @@ class Handler extends ExceptionHandler
return parent::render($request, $exception);
}
if ($exception instanceof NotFoundHttpException && $request->expectsJson()) {
// JSON error:
return response()->json(['message' => 'Resource not found', 'exception' => 'NotFoundHttpException'], 404);
}
if ($exception instanceof AuthenticationException && $request->expectsJson()) {
// somehow Laravel handler does not catch this:
return response()->json(['message' => 'Unauthenticated', 'exception' => 'AuthenticationException'], 401);
}
if ($request->expectsJson()) {
$isDebug = config('app.debug', false);
if ($isDebug) {