此方法可以放在钩子里
判断在不同的环境下,设置不同的内容显示
/** * 默认异常处理 */ $old_exception = set_exception_handler(NULL); set_exception_handler(function ($exception) use ($old_exception) { if ($exception instanceof qb_Exception) { $error = load_class('Exceptions', 'core'); $error->exception = $exception; $error->log_exception('error', 'Exception: ' . $exception->getMessage(), $exception->getFile(), $exception->getLine()); if (ENVIRONMENT === 'development' || $exception->getCode() != API_FAILURE) { if (ENVIRONMENT === 'development') { $message = $exception->getMessage() . PHP_EOL . PHP_EOL . $exception->getFile() . ' [' . $exception->getLine() . ']'; } else { $message = StatusCode::get_code_message($exception->getCode()); } showError($message, $exception->getCode()); } else { showError(); } } $old_exception && $old_exception($exception); });