Skip to content

Commit

Permalink
Improve exception message for Region ID (#124)
Browse files Browse the repository at this point in the history
  • Loading branch information
宋神宗 authored Apr 11, 2019
1 parent 6562adf commit 774aa9f
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 39 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# CHANGELOG

## 1.2.0 - 2019-04-11
- Improve exception message for `Region ID`.


## 1.1.1 - 2019-04-02
- Added endpoints for `batchcomputenew`, `privatelink`.
- Improve Region ID tips.
Expand Down
5 changes: 0 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,6 @@
"classmap": [
]
},
"extra": {
"branch-alias": {
"dev-master": "1.0-dev"
}
},
"config": {
"sort-packages": true,
"preferred-install": "dist",
Expand Down
2 changes: 1 addition & 1 deletion src/AlibabaCloud.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class AlibabaCloud
/**
* Version of the Client
*/
const VERSION = '1.1.1';
const VERSION = '1.2.0';

/**
* This static method can directly call the specific service.
Expand Down
12 changes: 1 addition & 11 deletions src/Request/Traits/AcsTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
namespace AlibabaCloud\Client\Request\Traits;

use AlibabaCloud\Client\AlibabaCloud;
use AlibabaCloud\Client\Config\Config;
use AlibabaCloud\Client\Exception\ClientException;
use AlibabaCloud\Client\Exception\ServerException;
use AlibabaCloud\Client\Filter\ApiFilter;
Expand Down Expand Up @@ -141,17 +140,8 @@ public function resolveUri()
}

if (!$host) {
$product = Config::get("endpoints.{$this->product}");
unset($product['global'], $product[$regionId]);
if ($product) {
$regions = implode(', ', array_keys($product));
$message = "Product {$this->product} does not support [{$regionId}], but supports [$regions]";
} else {
$message = "Can't resolve host for {$this->product} in $regionId";
}

throw new ClientException(
$message . ', you still can specify host via the host() method.',
"Did not find the {$this->product} host in {$regionId}, you can specify host by host() method.",
SDK::INVALID_REGION_ID
);
}
Expand Down
23 changes: 1 addition & 22 deletions tests/Unit/Request/AcsTraitTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -461,7 +461,7 @@ public function testFindDomainOnLocationService()

/**
* @expectedException \AlibabaCloud\Client\Exception\ClientException
* @expectedExceptionMessage Can't resolve host for no in cn-hangzhou, you still can specify host via the host() method.
* @expectedExceptionMessage Did not find the no host in cn-hangzhou, you can specify host by host() method.
* @throws ClientException
* @throws ServerException
*/
Expand Down Expand Up @@ -492,27 +492,6 @@ public function testFindDomainOnLocationServiceWithEmpty()
self::assertEquals('ecs-cn-hangzhou.aliyuncs.com', $request->uri->getHost());
}

/**
* @expectedException \AlibabaCloud\Client\Exception\ClientException
* @expectedExceptionMessage Product nlp does not support [cn-beijing], but supports [cn-shanghai], you still can specify host via the host() method.
* @throws ClientException
* @throws ServerException
*/
public function testReturnSupportsRegions()
{
// Setup
AlibabaCloud::cancelMock();
AlibabaCloud::setDefaultRegionId('cn-beijing');
AlibabaCloud::accessKeyClient('ak', 'bar')->asDefaultClient();

// Test
$request = AlibabaCloud::roa();
$request->product('nlp');

// Assert
$request->resolveUri();
}

protected function tearDown()
{
parent::tearDown();
Expand Down

0 comments on commit 774aa9f

Please sign in to comment.