0

I use Laravel 5.2

I wanted to change this error :

Whoops, looks like something went wrong.

first please see : Laravel

I created a new file resources/views/errors/404.blade.php but my app error didn't change !

it change just when not found url at route but when insert url injection in to $_GET it show "whoops .." yet

for example work for this link : http://domain.com/dgdgergehrhddg54d6g8

but not working for this injection : http://domain.com/listmanage=8 insert 9 instens of 8

error message when debug is true :

ErrorException: file.php line 215

Trying to get property of non-object

4
  • where did you change debug mode from env file or config? and did you try to access undefined route or send abort(404) to test? Commented Jul 19, 2016 at 21:47
  • FYI: "Whoops, [...]" errors in Laravel are HTTP 5XX errors, not 404. Commented Jul 19, 2016 at 22:01
  • i remove line APP_DEBUG in env file and changed debug mode from config- no- how can send abort(404) or try to access undefined route? Commented Jul 19, 2016 at 22:03
  • 5XX ? what is you mean? i trye to add 500.blade.php but didnt work Commented Jul 19, 2016 at 22:07

2 Answers 2

0

You are viewing that error page because of the environment you are into. As default, for local environments, the "Whoops" format is shown. For Production environments, the error/x.blade.php files are used.

To customize this you simply go to: ./app/Exceptions/Handler.php And modify the render function. You can do something like this:

public function render($request, Exception $e)
{
    // If an ErrorException is received and this enviroment is local
    if ($e instanceof \ErrorException && app()->environment() == 'local') {
        // Show customized page
        return response()->view('errors.404', [], $e->getCode());
    }

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

}

Cheers :)

Sign up to request clarification or add additional context in comments.

4 Comments

my app is not installed in localhost it is on VPS , so i should change APP_ENV=local in ENV file? and what is \ErrorException inside if commend im new user please description exactly thanks
no, your APP_ENV=production is fine then. Can you post the content of the Handler.php file? And, an ErrorException is the event that Laravel fires when an error is occurring.
yes i posted the content of the Handler.php but it did not work !
@MikelWilliams don't see it.
0

on Larvel 5.2 on your app/exceptions/handler.php just extend this method renderHttpException ie add this method to handler.php

/**
 * Render the given HttpException.
 *
 * @param  \Symfony\Component\HttpKernel\Exception\HttpException  $e
 * @return \Symfony\Component\HttpFoundation\Response
 */
protected function renderHttpException(HttpException $e)
{

   // to get status code ie 404, 503, 500
    $status = $e->getStatusCode();

    if (view()->exists("errors.{$status}")) {
        return response()->view("errors.{$status}", ['exception' => $e], $status, $e->getHeaders());
    } else {
        return $this->convertExceptionToResponse($e);
    }
}

Hope that helps.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.