mirror of
https://github.com/bs-community/blessing-skin-server.git
synced 2024-12-15 06:09:58 +08:00
41 lines
1012 B
PHP
41 lines
1012 B
PHP
|
<?php
|
||
|
/**
|
||
|
* @Author: printempw
|
||
|
* @Date: 2016-03-27 11:04:14
|
||
|
* @Last Modified by: printempw
|
||
|
* @Last Modified time: 2016-03-27 11:36:57
|
||
|
*/
|
||
|
|
||
|
class E extends Exception
|
||
|
{
|
||
|
/**
|
||
|
* Custom error handler
|
||
|
*
|
||
|
* @param string $message
|
||
|
* @param integer $code
|
||
|
* @param boolean $render, to show a error page
|
||
|
*/
|
||
|
function __construct($message = "Error occured.", $code = -1, $render = false) {
|
||
|
parent::__construct($message, $code);
|
||
|
if ($render) {
|
||
|
$this->showErrorPage();
|
||
|
} else {
|
||
|
$this->showErrorJson();
|
||
|
}
|
||
|
}
|
||
|
|
||
|
private function showErrorJson() {
|
||
|
$exception['errno'] = $this->code;
|
||
|
$exception['msg'] = $this->message;
|
||
|
header('Content-type: application/json; charset=utf-8');
|
||
|
exit(json_encode($exception));
|
||
|
}
|
||
|
|
||
|
private function showErrorPage() {
|
||
|
$message = $this->message;
|
||
|
$code = $this->code;
|
||
|
require BASE_DIR."/templates/error.tpl.php";
|
||
|
exit;
|
||
|
}
|
||
|
}
|