改进异常页面

This commit is contained in:
yunwuxin
2016-06-29 15:10:43 +08:00
parent 0aa1994ce3
commit 73fdd13482
3 changed files with 33 additions and 2 deletions

View File

@@ -349,6 +349,12 @@ class App
self::$debug = Config::get('app_debug'); self::$debug = Config::get('app_debug');
if (!self::$debug) { if (!self::$debug) {
ini_set('display_errors', 'Off'); ini_set('display_errors', 'Off');
} else {
//重新申请一块比较大的buffer
if (ob_get_level() > 0) {
ob_end_clean();
}
ob_start();
} }
// 应用命名空间 // 应用命名空间

View File

@@ -155,8 +155,10 @@ class Handle
while (ob_get_level() > 1) { while (ob_get_level() > 1) {
ob_end_clean(); ob_end_clean();
} }
$data['echo'] = ob_get_clean();
ob_start(); ob_start();
ob_implicit_flush(0);
extract($data); extract($data);
include Config::get('exception_tmpl'); include Config::get('exception_tmpl');
// 获取并清空缓存 // 获取并清空缓存

View File

@@ -124,6 +124,26 @@
background: #f8cbcb; background: #f8cbcb;
} }
.echo table {
width: 100%;
}
.echo pre {
padding: 16px;
overflow: auto;
font-size: 85%;
line-height: 1.45;
background-color: #f7f7f7;
border: 0;
border-radius: 3px;
font-family: Consolas, "Liberation Mono", Menlo, Courier, monospace;
}
.echo pre > pre {
padding: 0;
margin: 0;
}
/* Exception Info */ /* Exception Info */
.exception .message{ .exception .message{
padding: 12px; padding: 12px;
@@ -258,6 +278,9 @@
</style> </style>
</head> </head>
<body> <body>
<div class="echo">
<?php echo $echo;?>
</div>
<?php if(\think\App::$debug) { ?> <?php if(\think\App::$debug) { ?>
<div class="exception"> <div class="exception">
<div class="message"> <div class="message">