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