提交 1ed1767e 编写于 作者: lzc828's avatar lzc828

错误号码

上级 bc9bae5a
......@@ -553,7 +553,7 @@ class Build
} else if (method_exists($this->model, $name)) {
return $this->model->$name(...$arguments);
} else {
throw new DbException('Undefined method ' . $name);
throw new DbException('Undefined method ' . $name, 556);
}
}
......
......@@ -6,16 +6,20 @@ class Handler
{
public static function render(HttpException $e)
{
$e->response->code($e->getCode());
$code = $e->getCode();
if ($code === 0) {
$code = 1;
}
$e->response->code($code);
if ($e->response->getHttpRequest()->isJson()) {
return $e->response->json(format_json($e->getMessage(), $e->getCode(), $e->response->getHttpRequest()->id()));
return $e->response->json(format_json($e->getMessage(), $code, $e->response->getHttpRequest()->id()));
} else {
$file = _APP_PATH_VIEW_ . '/exceptions/' . $e->getCode() . '.php';
$file = _APP_PATH_VIEW_ . '/exceptions/' . $code . '.php';
if (file_exists($file)) {
return $e->response->tpl('exceptions/' . $e->getCode(), ['e' => $e]);
return $e->response->tpl('exceptions/' . $code, ['e' => $e]);
} else {
return $e->response->json(format_json($e->getMessage(), $e->getCode(), $e->response->getHttpRequest()->id()));
return $e->response->json(format_json($e->getMessage(), $code, $e->response->getHttpRequest()->id()));
}
}
}
......
......@@ -62,7 +62,7 @@ class Tcp
if ($r) {
return $client;
} else {
throw new \Exception('连接失败 tcp://' . $this->config['ip'] . ':' . $this->config['port']);
throw new \Exception('连接失败 tcp://' . $this->config['ip'] . ':' . $this->config['port'], 650);
}
}
......
......@@ -74,7 +74,7 @@ namespace One\Swoole {
$buffer = pack('N', 4 + strlen($buffer)) . $buffer;
$len = fwrite(self::$_connection, $buffer);
if ($len !== strlen($buffer)) {
throw new \Exception('writeToRemote fail');
throw new \Exception('writeToRemote fail', 11);
}
$data = msgpack_unpack($this->read());
if ($data === self::RPC_REMOTE_OBJ) {
......@@ -95,7 +95,7 @@ namespace One\Swoole {
while (1) {
$buffer = fread(self::$_connection, 8192);
if ($buffer === '' || $buffer === false) {
throw new \Exception('read from remote fail');
throw new \Exception('read from remote fail', 2);
}
$all_buffer .= $buffer;
$recv_len = strlen($all_buffer);
......@@ -118,7 +118,7 @@ namespace One\Swoole {
{
$connection = stream_socket_client($this->_rpc_server, $code, $msg, 3);
if (!$connection) {
throw new \Exception($msg);
throw new \Exception($msg,3);
}
stream_set_timeout($connection, $this->_time_out);
return $connection;
......
......@@ -19,7 +19,7 @@ use Swoole\Process;
*/
class Server
{
protected $conf = [];
/**
......@@ -94,7 +94,7 @@ class Server
public function onClose(\swoole_server $server, $fd, $reactor_id)
{
}
public function onPipeMessage(\swoole_server $server, $src_worker_id, $message)
......@@ -117,7 +117,7 @@ class Server
if (method_exists($this->server, $name)) {
return $this->server->$name(...$arguments);
} else {
throw new \Exception('方法不存在:' . $name);
throw new \Exception('方法不存在:' . $name, 10);
}
}
......
......@@ -10,6 +10,6 @@ if (!defined('_DEBUG_')) {
define('_DEBUG_', false);
}
define('_ONE_V_', '1.7.3');
define('_ONE_V_', '1.7.4');
require __DIR__ . '/helper.php';
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册