From 420725e262d16aedac7902421f7101e0be7fc108 Mon Sep 17 00:00:00 2001 From: dongwei <838456736@qq.com> Date: Sat, 19 Jan 2019 15:49:05 +0800 Subject: [PATCH] add rpc server no config exception --- src/Providers/ClientServiceProvider.php | 6 ++---- src/Providers/LumenServerServiceProvider.php | 5 ++++- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/Providers/ClientServiceProvider.php b/src/Providers/ClientServiceProvider.php index 454668c..6d91c13 100644 --- a/src/Providers/ClientServiceProvider.php +++ b/src/Providers/ClientServiceProvider.php @@ -12,16 +12,14 @@ class ClientServiceProvider extends ServiceProvider /** - * Register any application services. - * - * @return void + * @throws RpcServerException */ public function register() { $this->app->configure('rpc'); $config = config('rpc'); if (!is_array($config)) { - throw new RpcServerException("Application's Rpc Config Undefind", 500); + throw new RpcServerException("Application's Rpc Client Config Undefind", 500); } $this->app->singleton('rpc', function () use ($config) { return new Client($config); diff --git a/src/Providers/LumenServerServiceProvider.php b/src/Providers/LumenServerServiceProvider.php index 930f894..bc91a25 100644 --- a/src/Providers/LumenServerServiceProvider.php +++ b/src/Providers/LumenServerServiceProvider.php @@ -4,6 +4,7 @@ namespace JsonRpc\Providers; use App\Http\Middleware\JsonRpc; use Illuminate\Support\ServiceProvider; +use JsonRpc\Exception\RpcServerException; use JsonRpc\Middleware\Security; use JsonRpc\Server\JsonRpcDoc; use JsonRpc\Server\JsonRpcServer; @@ -33,7 +34,9 @@ class LumenServerServiceProvider extends ServiceProvider $this->app->configure('rpc'); $config = config('rpc.server'); - + if (!is_array($config)) { + throw new RpcServerException("Application's Rpc Server Config Undefind", 500); + } $callback = function () use ($config) { $server = new JsonRpcServer($config); return $server->handler();