This commit is contained in:
2020-09-18 17:19:05 +08:00
parent a8adb75813
commit a0e41f4c1f
+12 -1
View File
@@ -7,6 +7,7 @@ namespace Database;
use Snowflake\Abstracts\Component; use Snowflake\Abstracts\Component;
use Closure; use Closure;
use Exception; use Exception;
use Snowflake\Event;
use Snowflake\Snowflake; use Snowflake\Snowflake;
use Swoole\Coroutine; use Swoole\Coroutine;
@@ -179,9 +180,19 @@ class Pagination extends Component
{ {
$this->_group->add(1); $this->_group->add(1);
return Coroutine::create(function ($callback, $data, $param) { return Coroutine::create(function ($callback, $data, $param) {
try {
call_user_func($callback, $data, $param); call_user_func($callback, $data, $param);
} catch (\Throwable $exception) {
$this->addError($exception->getMessage());
} finally {
$this->_group->done(); $this->_group->done();
},$callback, $data, $param); $event = Snowflake::app()->getEvent();
if (!$event->exists(Event::EVENT_AFTER_REQUEST)) {
return;
}
$event->trigger(Event::EVENT_AFTER_REQUEST);
}
}, $callback, $data, $param);
} }