mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-08 11:04:30 -04:00
Merge branch 'develop' of github.com:invoiceninja/invoiceninja into develop
This commit is contained in:
commit
31d5e28b69
@ -1,5 +1,7 @@
|
|||||||
<?php namespace App\Exceptions;
|
<?php namespace App\Exceptions;
|
||||||
|
|
||||||
|
use Braintree\Util;
|
||||||
|
use Illuminate\Support\Facades\Response;
|
||||||
use Redirect;
|
use Redirect;
|
||||||
use Utils;
|
use Utils;
|
||||||
use Exception;
|
use Exception;
|
||||||
@ -69,7 +71,7 @@ class Handler extends ExceptionHandler
|
|||||||
{
|
{
|
||||||
if ($e instanceof ModelNotFoundException) {
|
if ($e instanceof ModelNotFoundException) {
|
||||||
return Redirect::to('/');
|
return Redirect::to('/');
|
||||||
} elseif ($e instanceof \Illuminate\Session\TokenMismatchException) {
|
} if ($e instanceof \Illuminate\Session\TokenMismatchException) {
|
||||||
// prevent loop since the page auto-submits
|
// prevent loop since the page auto-submits
|
||||||
if ($request->path() != 'get_started') {
|
if ($request->path() != 'get_started') {
|
||||||
// https://gist.github.com/jrmadsen67/bd0f9ad0ef1ed6bb594e
|
// https://gist.github.com/jrmadsen67/bd0f9ad0ef1ed6bb594e
|
||||||
@ -82,6 +84,40 @@ class Handler extends ExceptionHandler
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if($this->isHttpException($e))
|
||||||
|
{
|
||||||
|
switch ($e->getStatusCode())
|
||||||
|
{
|
||||||
|
// not found
|
||||||
|
case 404:
|
||||||
|
if($request->header('X-Ninja-Token') != '') {
|
||||||
|
//API request which has hit a route which does not exist
|
||||||
|
|
||||||
|
$error['error'] = ['message'=>'Route does not exist'];
|
||||||
|
$error = json_encode($error, JSON_PRETTY_PRINT);
|
||||||
|
$headers = Utils::getApiHeaders();
|
||||||
|
|
||||||
|
return response()->make($error, 404, $headers);
|
||||||
|
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
// internal error
|
||||||
|
case '500':
|
||||||
|
if($request->header('X-Ninja-Token') != '') {
|
||||||
|
//API request which produces 500 error
|
||||||
|
|
||||||
|
$error['error'] = ['message'=>'Internal Server Error'];
|
||||||
|
$error = json_encode($error, JSON_PRETTY_PRINT);
|
||||||
|
$headers = Utils::getApiHeaders();
|
||||||
|
|
||||||
|
return response()->make($error, 500, $headers);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// In production, except for maintenance mode, we'll show a custom error screen
|
// In production, except for maintenance mode, we'll show a custom error screen
|
||||||
if (Utils::isNinjaProd()
|
if (Utils::isNinjaProd()
|
||||||
&& !Utils::isDownForMaintenance()
|
&& !Utils::isDownForMaintenance()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user