相关疑难解决方法(0)

Laravel 5.7错误404处理页面位置

我在Laravel 5.7中找不到错误404页面的位置请帮忙.这是错误页面照片:https://imgur.com/a/Fs89isK

php error-handling laravel

7
推荐指数
1
解决办法
7422
查看次数

处理程序未捕获自动定位和令牌不匹配异常。Laravel

一段时间以来,我一直在尝试处理 laravel 抛出的异常。我尝试了很多东西,但似乎没有用。以下是我使用的语法:

public function render($request, Exception $e)
{
    //404 page when a model is not found
    if ($e instanceof ModelNotFoundException) {
        return response()->view('errors.404', [], 404);
    }elseif ($e instanceof \AuthorizationException) {
        return response()->view('errors.403', [], 403);
    }elseif ($e instanceof TokenMismatchException) {
        Flash::error('Sorry, your session seems to have expired. Please try again.');
        return redirect('/');
    }elseif ($e instanceof \ErrorException) {
        return response()->view('errors.500', [], 500);
    }else {
        return response()->view('errors.500', [], 500);
    }
    // return parent::render($request, $e);
}
Run Code Online (Sandbox Code Playgroud)

我已经包括以下内容:

use Exception;
use Illuminate\Auth\Access\AuthorizationException;
use Illuminate\Database\Eloquent\ModelNotFoundException; …
Run Code Online (Sandbox Code Playgroud)

php error-handling laravel

5
推荐指数
1
解决办法
593
查看次数

标签 统计

error-handling ×2

laravel ×2

php ×2