# 通過Error類拋出錯誤
XPHP內置了錯誤處理引擎`Error`類,它不僅于內置的日志系統完美融合,而且符合用戶習慣,錯誤界面美觀,功能全面,模板可以自定義。
## 拋出一個錯誤
首先,引入錯誤處理引擎:
```php
use X\Error;
```
然后,在需要拋出錯誤的時候,執行:
```php
Error::Show("錯誤編號","錯誤信息","跳轉地址(留空即為首頁)","跳轉時間(留空即為3)");
```
## 自定義錯誤模板
錯誤模板是 `System/Error` 。
您可以自行修改。
默認的模板:
```handlebars
<html>
<head>
<title>XPHP {{$L['System']['Error']}}</title>
<style>
body{
margin:0;
padding:30px;
font:12px/1.5 "Microsoft Yahei UI",Helvetica,Arial,Verdana,sans-serif;
}
h1{
margin:0;
font-size:48px;
font-weight:normal;
line-height:48px;
}
strong{
display:inline-block;
width:65px;
}
</style>
</head>
<body>
<h1>{{$L['System']['Error']}} {{$no ? "#".$no : ""}} :</h1>
<h3>
{{$e}}
</h3>
<p>{{$L['System']['WeHadRecordThisError']}}</p>
{{# if ($jump){ }}
<a href='{{$jump}}'>{{$L['System']['jumpNow']}}</a> ({{$sec}}{{$L['System']['SecondsAfterAutoJump']}})
<script type="text/javascript">
window.setTimeout("window.location.href='{{$jump}}';",{{$sec}}*1000);
</script>
{{# }else{ }}
<a href='/'>{{$L['System']['BackHome']}}</a>
{{# } }}
</body>
</html>
```