report() 方法用于报告或记录异常。 它也可以用来发送日志例外类似 sentry, bugsnag 等外部扩展服务
除了这两种方法,app\exceptions\handler 类包含一个一个重要属性名为 “$dontreport”。此属性采用的异常类型数组将不会被日志记录。
一些异常描述http错误代码类似:404,500等。要在应用程序中的任何地方产生这样响应,你可以按如下方式使用abort()方法。
abort(404)
laravel使得让我们很容易使用每个单独的错误代码来自定义错误页。 例如,如果想设计的自定义页面错误代码:404, 你可以创建一个视图为 :resources/views/errors/404.blade.php。同样的道理,如果你想设计错误代码是500的错误页,它应存放在:resources/views/errors/500.blade.php.
第1步 - 添加以下行到文件 : app/http/routes.php
route::get('/error',function(){
abort(404);
});
resources/views/errors/404.blade.php
<!doctype html>
<html>
<head>
<title>404页面</title>
<link href = "https://fonts.googleapis.com/css?family=lato:100" rel = "stylesheet"
type = "text/css">
<style>
html, body {
height: 100%;
}
body {
margin: 0;
padding: 0;
width: 100%;
color: #b0bec5;
display: table;
font-weight: 100;
'lato';
}
.container {
text-align: center;
display: table-cell;
vertical-align: middle;
}
.content {
text-align: center;
display: inline-block;
}
.title {
font-size: 72px;
margin-bottom: 40px;
}
</style>
</head>
<body>
<div class = "container">
<div class = "content">
<div class = "title">404 错误</div>
</div>
</div>
</body>
</html>
http://localhost:8000/error

