From a0e41f4c1ff7b5c866fa3d51db4292a25390e8bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mr=C2=B7x?= Date: Fri, 18 Sep 2020 17:19:05 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B9=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Database/Pagination.php | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/Database/Pagination.php b/Database/Pagination.php index 05d4a7a1..d7491541 100644 --- a/Database/Pagination.php +++ b/Database/Pagination.php @@ -7,6 +7,7 @@ namespace Database; use Snowflake\Abstracts\Component; use Closure; use Exception; +use Snowflake\Event; use Snowflake\Snowflake; use Swoole\Coroutine; @@ -179,9 +180,19 @@ class Pagination extends Component { $this->_group->add(1); return Coroutine::create(function ($callback, $data, $param) { - call_user_func($callback, $data, $param); - $this->_group->done(); - },$callback, $data, $param); + try { + call_user_func($callback, $data, $param); + } catch (\Throwable $exception) { + $this->addError($exception->getMessage()); + } finally { + $this->_group->done(); + $event = Snowflake::app()->getEvent(); + if (!$event->exists(Event::EVENT_AFTER_REQUEST)) { + return; + } + $event->trigger(Event::EVENT_AFTER_REQUEST); + } + }, $callback, $data, $param); }