Unverified Commit 79c47fa6 authored by Viral Solani's avatar Viral Solani Committed by GitHub

Merge pull request #163 from viralsolani/analysis-8QW0Ao

Apply fixes from StyleCI
parents 5210f03f 8b731819
......@@ -4,14 +4,12 @@ namespace App\Exceptions;
use Exception;
use Illuminate\Auth\AuthenticationException;
use Illuminate\Database\Eloquent\ModelNotFoundException;
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
use Illuminate\Session\TokenMismatchException;
use Illuminate\Database\Eloquent\ModelNotFoundException;
use Illuminate\Validation\ValidationException;
use Symfony\Component\HttpKernel\Exception\MethodNotAllowedHttpException;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use Symfony\Component\HttpKernel\Exception\UnauthorizedHttpException;
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
use Illuminate\Validation\ValidationException;
class Handler extends ExceptionHandler
{
......@@ -68,54 +66,48 @@ class Handler extends ExceptionHandler
return redirect()->back()->withInput()->withFlashDanger($exception->getMessage());
}
if(strpos($request->url(), '/api/') !== false)
{
\Log::debug("API Request Exception - ". $request->url() ." - " . $exception->getMessage() . (!empty($request->all()) ? ' - ' . json_encode($request->except(['password'])) : ''));
if (strpos($request->url(), '/api/') !== false) {
\Log::debug('API Request Exception - '.$request->url().' - '.$exception->getMessage().(!empty($request->all()) ? ' - '.json_encode($request->except(['password'])) : ''));
if($exception instanceof MethodNotAllowedHttpException)
{
if ($exception instanceof MethodNotAllowedHttpException) {
return response()->json((object) [
'status' => false,
'errorCode' => 'METHOD_NOT_ALLOWED',
'message' => 'Please check HTTP Request Method. - MethodNotAllowedHttpException'
'message' => 'Please check HTTP Request Method. - MethodNotAllowedHttpException',
], 403);
}
if($exception instanceof NotFoundHttpException)
{
if ($exception instanceof NotFoundHttpException) {
return response()->json((object) [
'status' => false,
'errorCode' => 'URL_NOT_FOUND',
'message' => 'Please check your URL to make sure request is formatted properly. - NotFoundHttpException'
'message' => 'Please check your URL to make sure request is formatted properly. - NotFoundHttpException',
], 403);
}
if($exception instanceof GeneralException)
{
if ($exception instanceof GeneralException) {
return response()->json((object) [
'status' => false,
'errorCode' => 'EXCEPTION',
'message' => $exception->getMessage()
'message' => $exception->getMessage(),
], 403);
}
if($exception instanceof ModelNotFoundException)
{
if ($exception instanceof ModelNotFoundException) {
return response()->json((object) [
'status' => false,
'errorCode' => 'ITEM_NOT_FOUND',
'message' => 'Item could not be found. Please check identifier.'
'message' => 'Item could not be found. Please check identifier.',
], 403);
}
if($exception instanceof ValidationException)
{
\Log::debug("API Validation Exception - " . json_encode($exception->validator->messages()));
if ($exception instanceof ValidationException) {
\Log::debug('API Validation Exception - '.json_encode($exception->validator->messages()));
return response()->json((object) [
'status' => false,
'errorCode' => 'VALIDATION_EXCEPTION',
'messages' => $exception->validator->messages()
'messages' => $exception->validator->messages(),
], 403);
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment