改名
This commit is contained in:
@@ -198,9 +198,7 @@ class Loader extends BaseObject
|
|||||||
|
|
||||||
$this->_classes[$replace->getName()] = $_array;
|
$this->_classes[$replace->getName()] = $_array;
|
||||||
} catch (Throwable $throwable) {
|
} catch (Throwable $throwable) {
|
||||||
$this->error($throwable->getMessage());
|
$this->addError($throwable, 'throwable');
|
||||||
$this->error($throwable->getFile());
|
|
||||||
$this->error($throwable->getLine());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -198,7 +198,7 @@ class Pagination extends Component
|
|||||||
try {
|
try {
|
||||||
call_user_func($callback, $data, $param);
|
call_user_func($callback, $data, $param);
|
||||||
} catch (\Throwable $exception) {
|
} catch (\Throwable $exception) {
|
||||||
$this->addError($exception);
|
$this->addError($exception, 'throwable');
|
||||||
} finally {
|
} finally {
|
||||||
$event = Snowflake::app()->getEvent();
|
$event = Snowflake::app()->getEvent();
|
||||||
$event->trigger(Event::SYSTEM_RESOURCE_RELEASES);
|
$event->trigger(Event::SYSTEM_RESOURCE_RELEASES);
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ namespace {$namespace};
|
|||||||
|
|
||||||
$import = $this->getImports($path['path'] . '/' . $managerName . 'Controller.php', $class);
|
$import = $this->getImports($path['path'] . '/' . $managerName . 'Controller.php', $class);
|
||||||
} catch (\Throwable $Exception) {
|
} catch (\Throwable $Exception) {
|
||||||
exit(logger()->addError($Exception));
|
exit(logger()->addError($Exception, 'throwable'));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$import = "use Snowflake;
|
$import = "use Snowflake;
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ namespace App\Http\Interceptor;
|
|||||||
|
|
||||||
$html .= $this->getImports($file, $class);
|
$html .= $this->getImports($file, $class);
|
||||||
} catch (\Throwable $exception) {
|
} catch (\Throwable $exception) {
|
||||||
return logger()->addError($exception);
|
return logger()->addError($exception, 'throwable');
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$html .= '
|
$html .= '
|
||||||
|
|||||||
+1
-1
@@ -68,7 +68,7 @@ namespace ' . $namespace . ';
|
|||||||
$html .= $imports . PHP_EOL;
|
$html .= $imports . PHP_EOL;
|
||||||
}
|
}
|
||||||
} catch (\Throwable $e) {
|
} catch (\Throwable $e) {
|
||||||
logger()->error($e->getMessage());
|
logger()->addError($e,'throwable');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ abstract class Callback extends HttpService
|
|||||||
|
|
||||||
$this->eventNotify($message);
|
$this->eventNotify($message);
|
||||||
} catch (\Throwable $exception) {
|
} catch (\Throwable $exception) {
|
||||||
$this->addError($exception);
|
$this->addError($exception,'throwable');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -66,6 +66,7 @@ class Client extends ClientAbstracts
|
|||||||
}
|
}
|
||||||
return $this->fail($client->getStatusCode(), $message, $body, $client->getHeaders());
|
return $this->fail($client->getStatusCode(), $message, $body, $client->getHeaders());
|
||||||
} catch (\Throwable $exception) {
|
} catch (\Throwable $exception) {
|
||||||
|
$this->addError($exception,'rpc');
|
||||||
return $this->fail(500, $exception->getMessage(), [
|
return $this->fail(500, $exception->getMessage(), [
|
||||||
'file' => $exception->getFile(),
|
'file' => $exception->getFile(),
|
||||||
'line' => $exception->getLine()
|
'line' => $exception->getLine()
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ class OnClose extends Callback
|
|||||||
try {
|
try {
|
||||||
$this->execute($server, $fd);
|
$this->execute($server, $fd);
|
||||||
} catch (\Throwable $exception) {
|
} catch (\Throwable $exception) {
|
||||||
$this->addError($exception);
|
$this->addError($exception,'throwable');
|
||||||
} finally {
|
} finally {
|
||||||
fire(Event::SYSTEM_RESOURCE_RELEASES);
|
fire(Event::SYSTEM_RESOURCE_RELEASES);
|
||||||
logger()->insert();
|
logger()->insert();
|
||||||
|
|||||||
@@ -97,7 +97,7 @@ class OnHandshake extends Callback
|
|||||||
$eventName = 'listen ' . $clientInfo['server_port'] . ' ' . Event::SERVER_HANDSHAKE;
|
$eventName = 'listen ' . $clientInfo['server_port'] . ' ' . Event::SERVER_HANDSHAKE;
|
||||||
$event->trigger($eventName, [$request, $response]);
|
$event->trigger($eventName, [$request, $response]);
|
||||||
} catch (\Throwable $exception) {
|
} catch (\Throwable $exception) {
|
||||||
$this->addError($exception);
|
$this->addError($exception,'throwable');
|
||||||
$this->disconnect($response, 500);
|
$this->disconnect($response, 500);
|
||||||
} finally {
|
} finally {
|
||||||
fire(Event::SYSTEM_RESOURCE_CLEAN);
|
fire(Event::SYSTEM_RESOURCE_CLEAN);
|
||||||
|
|||||||
@@ -65,6 +65,7 @@ class OnRequest extends Callback
|
|||||||
|
|
||||||
return $result;
|
return $result;
|
||||||
} catch (ExitException | Error | \Throwable $exception) {
|
} catch (ExitException | Error | \Throwable $exception) {
|
||||||
|
$this->addError($exception, 'throwable');
|
||||||
return $this->sendErrorMessage($request, $response, $exception);
|
return $this->sendErrorMessage($request, $response, $exception);
|
||||||
} finally {
|
} finally {
|
||||||
$this->event->trigger(Event::SYSTEM_RESOURCE_RELEASES);
|
$this->event->trigger(Event::SYSTEM_RESOURCE_RELEASES);
|
||||||
|
|||||||
@@ -118,7 +118,7 @@ class OnTask extends Callback
|
|||||||
} catch (\Throwable $exception) {
|
} catch (\Throwable $exception) {
|
||||||
$finish['status'] = 'error';
|
$finish['status'] = 'error';
|
||||||
$finish['info'] = $this->format($exception);
|
$finish['info'] = $this->format($exception);
|
||||||
$this->error($exception, 'Task');
|
$this->addError($exception, 'Task');
|
||||||
|
|
||||||
return $finish;
|
return $finish;
|
||||||
} finally {
|
} finally {
|
||||||
|
|||||||
@@ -73,7 +73,7 @@ class OnWorkerStart extends Callback
|
|||||||
try {
|
try {
|
||||||
fire(Event::SERVER_WORKER_START, [$worker_id]);
|
fire(Event::SERVER_WORKER_START, [$worker_id]);
|
||||||
} catch (\Throwable $exception) {
|
} catch (\Throwable $exception) {
|
||||||
$this->addError($exception);
|
$this->addError($exception,'throwable');
|
||||||
write($exception->getMessage(), 'worker');
|
write($exception->getMessage(), 'worker');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -287,7 +287,7 @@ class Node extends HttpService
|
|||||||
return [$reflect->newInstance(), $action];
|
return [$reflect->newInstance(), $action];
|
||||||
} catch (Throwable $exception) {
|
} catch (Throwable $exception) {
|
||||||
$this->_error = $exception->getMessage();
|
$this->_error = $exception->getMessage();
|
||||||
$this->error($exception, 'router');
|
$this->addError($exception, 'router');
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -592,7 +592,7 @@ class Node extends HttpService
|
|||||||
}
|
}
|
||||||
return $this->runWith(...func_get_args());
|
return $this->runWith(...func_get_args());
|
||||||
} catch (Throwable $throwable) {
|
} catch (Throwable $throwable) {
|
||||||
$this->error($throwable->getMessage());
|
$this->addError($throwable->getMessage(),'throwable');
|
||||||
return Json::to(401, $throwable->getMessage());
|
return Json::to(401, $throwable->getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -38,6 +38,7 @@ class Reduce
|
|||||||
}
|
}
|
||||||
return $pipe->onHandler($request, $passable);
|
return $pipe->onHandler($request, $passable);
|
||||||
} catch (\Throwable $throwable) {
|
} catch (\Throwable $throwable) {
|
||||||
|
logger()->addError($throwable, 'throwable');
|
||||||
return Json::to(0, $throwable);
|
return Json::to(0, $throwable);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -515,7 +515,7 @@ class Router extends HttpService implements RouterInterface
|
|||||||
}
|
}
|
||||||
return $node->afterDispatch($response);
|
return $node->afterDispatch($response);
|
||||||
} catch (\Throwable $exception) {
|
} catch (\Throwable $exception) {
|
||||||
$this->addError($exception);
|
$this->addError($exception,'throwable');
|
||||||
|
|
||||||
$Code = $exception->getCode() == 0 ? 500 : $exception->getCode();
|
$Code = $exception->getCode() == 0 ? 500 : $exception->getCode();
|
||||||
|
|
||||||
@@ -659,7 +659,7 @@ class Router extends HttpService implements RouterInterface
|
|||||||
$router = $this;
|
$router = $this;
|
||||||
include_once "{$files}";
|
include_once "{$files}";
|
||||||
} catch (\Throwable $exception) {
|
} catch (\Throwable $exception) {
|
||||||
$this->error($exception);
|
$this->addError($exception,'throwable');
|
||||||
} finally {
|
} finally {
|
||||||
if (isset($exception)) {
|
if (isset($exception)) {
|
||||||
unset($exception);
|
unset($exception);
|
||||||
|
|||||||
@@ -520,7 +520,7 @@ class Server extends HttpService
|
|||||||
$annotation->instanceDirectoryFiles(RPC_SERVICE_PATH);
|
$annotation->instanceDirectoryFiles(RPC_SERVICE_PATH);
|
||||||
$annotation->instanceDirectoryFiles(RPC_CLIENT_PATH);
|
$annotation->instanceDirectoryFiles(RPC_CLIENT_PATH);
|
||||||
} catch (\Throwable $exception) {
|
} catch (\Throwable $exception) {
|
||||||
$this->addError($exception);
|
$this->addError($exception,'throwable');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
+4
-4
@@ -58,7 +58,7 @@ class Kafka extends \Snowflake\Process\Process
|
|||||||
$this->resolve($topic, $conf['interval'] ?? 1000);
|
$this->resolve($topic, $conf['interval'] ?? 1000);
|
||||||
} while (true);
|
} while (true);
|
||||||
} catch (Throwable $exception) {
|
} catch (Throwable $exception) {
|
||||||
$this->application->error($exception);
|
logger()->addError($exception,'throwable');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -85,7 +85,7 @@ class Kafka extends \Snowflake\Process\Process
|
|||||||
$this->application->error($message->errstr());
|
$this->application->error($message->errstr());
|
||||||
}
|
}
|
||||||
} catch (Throwable $exception) {
|
} catch (Throwable $exception) {
|
||||||
$this->application->error($exception);
|
logger()->addError($exception,'throwable');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -111,7 +111,7 @@ class Kafka extends \Snowflake\Process\Process
|
|||||||
}
|
}
|
||||||
$class->onHandler(Snowflake::createObject(Struct::class, [$topic, $message]));
|
$class->onHandler(Snowflake::createObject(Struct::class, [$topic, $message]));
|
||||||
} catch (Throwable $exception) {
|
} catch (Throwable $exception) {
|
||||||
$this->application->error($exception);
|
logger()->addError($exception,'throwable');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -148,7 +148,7 @@ class Kafka extends \Snowflake\Process\Process
|
|||||||
|
|
||||||
return [$conf, $topicConf, $kafka];
|
return [$conf, $topicConf, $kafka];
|
||||||
} catch (Throwable $exception) {
|
} catch (Throwable $exception) {
|
||||||
$this->application->error($exception);
|
logger()->addError($exception,'throwable');
|
||||||
|
|
||||||
return [null, null, null];
|
return [null, null, null];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ class Consumer extends Process
|
|||||||
Consumer::addTask($crontab);
|
Consumer::addTask($crontab);
|
||||||
}
|
}
|
||||||
} catch (\Throwable $throwable) {
|
} catch (\Throwable $throwable) {
|
||||||
$this->application->addError($throwable->getMessage());
|
logger()->addError($throwable->getMessage(),'throwable');
|
||||||
} finally {
|
} finally {
|
||||||
fire(Event::SYSTEM_RESOURCE_RELEASES);
|
fire(Event::SYSTEM_RESOURCE_RELEASES);
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -232,7 +232,7 @@ class Event extends BaseObject
|
|||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
} catch (\Throwable $throwable) {
|
} catch (\Throwable $throwable) {
|
||||||
return $this->addError($throwable);
|
return $this->addError($throwable,'throwable');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -232,7 +232,7 @@ class ServerInotify extends Process
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 清理所有inotify监听
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public function clearWatch()
|
public function clearWatch()
|
||||||
{
|
{
|
||||||
@@ -240,6 +240,7 @@ class ServerInotify extends Process
|
|||||||
try {
|
try {
|
||||||
inotify_rm_watch($this->inotify, $wd);
|
inotify_rm_watch($this->inotify, $wd);
|
||||||
} catch (\Throwable $exception) {
|
} catch (\Throwable $exception) {
|
||||||
|
logger()->addError($exception, 'throwable');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$this->watchFiles = [];
|
$this->watchFiles = [];
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ use HttpServer\Service\Receive;
|
|||||||
use HttpServer\Service\Websocket;
|
use HttpServer\Service\Websocket;
|
||||||
use JetBrains\PhpStorm\Pure;
|
use JetBrains\PhpStorm\Pure;
|
||||||
use Snowflake\Abstracts\Config;
|
use Snowflake\Abstracts\Config;
|
||||||
|
use Snowflake\Application;
|
||||||
use Snowflake\Error\Logger;
|
use Snowflake\Error\Logger;
|
||||||
use Snowflake\Exception\ComponentException;
|
use Snowflake\Exception\ComponentException;
|
||||||
use Snowflake\Exception\ConfigException;
|
use Snowflake\Exception\ConfigException;
|
||||||
@@ -319,6 +320,19 @@ if (!function_exists('aop')) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (!function_exists('app')) {
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return Application|null
|
||||||
|
*/
|
||||||
|
#[Pure] function app(): ?Application
|
||||||
|
{
|
||||||
|
return Snowflake::app();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
if (!function_exists('instance_load')) {
|
if (!function_exists('instance_load')) {
|
||||||
|
|
||||||
function instance_load()
|
function instance_load()
|
||||||
|
|||||||
Reference in New Issue
Block a user