GrahamCampbell / Laravel-Exceptions

Provides a powerful error response system for Laravel
https://gjcampbell.co.uk
MIT License
587 stars 54 forks source link

Error pages (ie. 404) are not being shown; converts to a 500 page #50

Closed simplenotezy closed 8 years ago

simplenotezy commented 8 years ago

After installing this package, our 404, 500, 503, etc pages are gone. All we get is a white page.

In bootstrap/app.php this is how I call your exceptionhandler

$app->singleton(
    'Illuminate\Contracts\Debug\ExceptionHandler',
    'GrahamCampbell\Exceptions\ExceptionHandler' // before: App\Exceptions\Handler.
);

If I change the ExceptionHandler to use the native App\Exceptions\Handler error pages are shown just fine. Therefore it must be something to do with your package.

If debugmode is true I see default Whoops page. If debug mode is false I see white pages.

GrahamCampbell commented 8 years ago

This is probably because your views are broken, not this package?

simplenotezy commented 8 years ago

Well I guess not, since if I change the ExceptionHandler to use the native App\Exceptions\Handler error pages are shown just fine.

GrahamCampbell commented 8 years ago

Can I see your exception handler code?

simplenotezy commented 8 years ago

This is all I have:

$app->singleton(
    'Illuminate\Contracts\Debug\ExceptionHandler',
    'GrahamCampbell\Exceptions\ExceptionHandler' // before: App\Exceptions\Handler.
);
GrahamCampbell commented 8 years ago

This is all I have:

No it's not...

GrahamCampbell commented 8 years ago

App\Exceptions\Handler error pages are shown just fine.

GrahamCampbell commented 8 years ago

Telling me you have white page is a useless as saying "it's broken" with no context. Can you provide logs please.

simplenotezy commented 8 years ago
<?php namespace App\Exceptions;

    use Exception;
    //use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;

    //use GrahamCampbell\Exceptions\ExceptionHandler as ExceptionHandler;

    use Bugsnag\BugsnagLaravel\BugsnagExceptionHandler as ExceptionHandler;
    use Illuminate\Database\Eloquent\ModelNotFoundException as ModelNotFoundException;

    use Illuminate\Auth\Access\AuthorizationException;
    use Symfony\Component\HttpKernel\Exception\HttpException;
    use Illuminate\Foundation\Validation\ValidationException;
    use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;

    use Illuminate\Http\Exception\HttpResponseException;

    class Handler extends ExceptionHandler {

        /**
         * A list of the exception types that should not be reported.
         *
         * @var array
         */
        protected $dontReport = [
            NotFoundHttpException::class,

            AuthorizationException::class,
            HttpException::class,
            ModelNotFoundException::class,
            ValidationException::class,
        ];

        /**
         * Report or log an exception.
         *
         * This is a great spot to send exceptions to Sentry, Bugsnag, etc.
         *
         * @param  \Exception  $e
         * @return void
         */
        public function report(Exception $e)
        {
            return parent::report($e);
        }

        /**
         * Render an exception into an HTTP response.
         *
         * @param  \Illuminate\Http\Request  $request
         * @param  \Exception  $e
         * @return \Illuminate\Http\Response
         */
        public function render($request, Exception $e)
        {

            return parent::render($request, $e);
        }

    }
simplenotezy commented 8 years ago

For some strange reason, behavior has changed a bit... I'm sorry, it does not seem related to your package. However, the code you previously provided me, when trying to get Whoops + bugsnag to work, seems to be causing the issue. The Logger library.

This is my Loggers config: <?php

/*
 * This file is part of Alt Three Logger.
 *
 * (c) Alt Three Services Limited
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

return [

    /*
    |--------------------------------------------------------------------------
    | Loggers
    |--------------------------------------------------------------------------
    |
    | Here are each of the loggers to call under the hood while logging.
    |
    */

    'loggers' => env('APP_DEBUG', false) ? ['Illuminate\Log\Writer' => ['*']] : [
        'AltThree\Bugsnag\Logger'   => ['error', 'critical', 'alert', 'emergency'],
        'AltThree\Logify\Logger'    => ['*']
    ],

];

When debugmode is OFF, views are not shown. When debugmode is on, views are shown.

simplenotezy commented 8 years ago

So I figured it out; the logger.php you previously pasted had "'AltThree\Logify\Logger" in the config, which is a library I do not have included. Changing this to Illuminate\Log\Writer works fine. I'm sorry for the confusion.

Thanks for all your help.

simplenotezy commented 8 years ago

However. When changing back to using your ExceptionsHandler, I simply get a 500 error page if debug mode is off, instead of seeing the expected 500 view.

simplenotezy commented 8 years ago

Nothing is in the error.log. I see this page:

image

simplenotezy commented 8 years ago

So when using ->firstOrFail() (forcing it to fail) it generates this 500 error page:

image

I would expect to see a 404 page.

GrahamCampbell commented 8 years ago

I would expect to see a 404 page.

As I said, I'd say 500 is correct, but I'd like to add the transformer so that people can transform it to 404.

GrahamCampbell commented 8 years ago

Duplicate of https://github.com/GrahamCampbell/Laravel-Exceptions/issues/49.