O
O
ObehanProger2019-03-06 16:20:24
Laravel
ObehanProger, 2019-03-06 16:20:24

Why doesn't Laravel's custom exception work?

IndexController.php:

public function testException(){
        try{
            echo $test;
        }
        catch(Exception $e) {
                throw new 
 PostsInCategoryNotFoundErrorException($e);
        }

    }

PostsInCategoryNotFoundErrorException.php
namespace App\Exceptions;

use Exception;

class PostsInCategoryNotFoundErrorException extends Exception
{

}

handler.php
public function render($request, Exception $exception)
{
    if ($exception instanceof PostsInCategoryNotFoundErrorException) {
      echo 'Ошибка в переменной';
    }
    return parent::render($request, $exception);
}

It still gives its standard error page "Whoops, looks like something went wrong"

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question