Skip to content

Commit

Permalink
close #12
Browse files Browse the repository at this point in the history
  • Loading branch information
chaz6chez committed Jan 9, 2024
1 parent 577f0e0 commit 70dfbc6
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

use GuzzleHttp\Handler\MockHandler;
use Workbunny\WebmanNacos\Exception\NacosException;
use Workbunny\WebmanNacos\Exception\PluginDisableException;
use Workbunny\WebmanNacos\Provider\ConfigProvider;
use Workbunny\WebmanNacos\Provider\InstanceProvider;
use Workbunny\WebmanNacos\Provider\OperatorProvider;
Expand Down Expand Up @@ -69,6 +70,10 @@ class Client
*/
public static function channel(string $name = 'default'): Client
{
// 如果插件关闭,则抛出一个特定异常
if (!config('plugin.workbunny.webman-nacos.app.enable', true)) {
throw new PluginDisableException();
}
$channel = config('plugin.workbunny.webman-nacos.channel', []);
if(empty($config = $channel[$name] ?? [])){
throw new NacosException("Channel config $name is invalid.");
Expand Down
18 changes: 18 additions & 0 deletions src/Exception/PluginDisableException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php
/**
* This file is part of workbunny.
*
* Redistributions of files must retain the above copyright notice.
*
* @author chaz6chez<[email protected]>
* @copyright chaz6chez<[email protected]>
* @link https://github.com/workbunny/webman-nacos
* @license https://github.com/workbunny/webman-nacos/blob/main/LICENSE
*/
declare(strict_types=1);

namespace Workbunny\WebmanNacos\Exception;

class PluginDisableException extends \RuntimeException
{
}

0 comments on commit 70dfbc6

Please sign in to comment.