app/Exceptions/Handler.php
/**
     * Render an exception into an HTTP response.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  \Exception  $exception
     * @return \Illuminate\Http\Response
     */
Render an exception into an HTTP response.
Render an exception into an HTTP response .
public function render($request, Exception $exception)
    {
        if($exception instanceof NotFoundHttpException) {
            return response()->json([
                'error' => [
                    'description' => 'URI invalido',
                    'messages' => $exception->getMessage()
                ]
            ], 404);
        }
        if($exception instanceof MethodNotAllowedHttpException) {
            return response()->json([
                'error' => [
                    'description' => 'Método não permitido',
                    'messages' => $exception->getMessage()
                ]
            ], 405);
        }
        if($exception instanceof ModelNotFoundException) {
            return response()->json([
                'error' => [
                    'description' => 'Model não encontrado',
                    'messages' => $exception->getMessage()
                ]
            ], 404);
        }
        if($exception instanceof GenericException) {
            return response()->json([
                'error' => [
                    'description' => $exception->getMessage(),
                    'messages' => $exception->getMessage()
                ]
            ], 400);
        }
        return parent::render($request, $exception);
    }
public function render ( $ request , Exception $ exception ) { if ( $ exception instanceof NotFoundHttpException ) { return response ( ) -> json ( [ 'error' => [ 'description' => 'URI invalido' , 'messages' => $ exception -> getMessage ( ) ] ] , 404 ) ; } if ( $ exception instanceof MethodNotAllowedHttpException ) { return response ( ) -> json ( [ 'error' => [ 'description' => 'Método não permitido', 'messages' => $ exception -> getMessage ( ) ] ] , 405 ) ; } if ( $ exception instanceof ModelNotFoundException ) { return response ( ) -> json ( [ 'error' => [ 'description' => 'Model não encontrado', 'messages' => $ exception -> getMessage ( ) ] ] , 404 ) ; } if ( $ exception instanceof GenericException ) { return response ( ) -> json ( [ 'error' => [ 'description' => $ exception -> getMessage ( ) , 'messages' => $ exception -> getMessage ( ) ] ] , 400 ) ; } return parent :: render ( $ request , $ exception ) ; }
Render an exception into an HTTP response.
Render an exception into an HTTP response .