Skip to content

Commit 526740e

Browse files
committed
Add EndpointResolutionError
1 parent 2a4e6f0 commit 526740e

File tree

3 files changed

+13
-6
lines changed

3 files changed

+13
-6
lines changed

packages/smithy-aws-core/src/smithy_aws_core/endpoints/standard_regional.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import smithy_core
77
from smithy_core import URI
88
from smithy_http.aio.interfaces import EndpointResolver
9-
from smithy_http.endpoints import Endpoint
9+
from smithy_http.endpoints import Endpoint, EndpointResolutionError
1010

1111

1212
@dataclass(kw_only=True)
@@ -35,7 +35,7 @@ async def resolve_endpoint(self, params: RegionalEndpointParameters) -> Endpoint
3535

3636
# This will end up getting wrapped in the client.
3737
if parsed.hostname is None:
38-
raise ValueError(
38+
raise EndpointResolutionError(
3939
f"Unable to parse hostname from provided URI: {params.sdk_endpoint}"
4040
)
4141

@@ -56,6 +56,6 @@ async def resolve_endpoint(self, params: RegionalEndpointParameters) -> Endpoint
5656

5757
return Endpoint(uri=URI(host=hostname))
5858

59-
raise ValueError(
59+
raise EndpointResolutionError(
6060
"Unable to resolve endpoint - either endpoint_url or region are required."
6161
)

packages/smithy-http/src/smithy_http/aio/endpoints.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from smithy_core import URI
66

77
from .. import interfaces as http_interfaces
8-
from ..endpoints import Endpoint, StaticEndpointParams
8+
from ..endpoints import Endpoint, StaticEndpointParams, EndpointResolutionError
99
from . import interfaces as http_aio_interfaces
1010

1111

@@ -18,7 +18,9 @@ async def resolve_endpoint(
1818
self, params: StaticEndpointParams
1919
) -> http_interfaces.Endpoint:
2020
if params.uri is None:
21-
raise ValueError("Unable to resolve endpoint: endpoint_uri is required")
21+
raise EndpointResolutionError(
22+
"Unable to resolve endpoint: endpoint_uri is required"
23+
)
2224

2325
# If it's not a string, it's already a parsed URI so just pass it along.
2426
if not isinstance(params.uri, str):
@@ -30,7 +32,7 @@ async def resolve_endpoint(
3032

3133
# This will end up getting wrapped in the client.
3234
if parsed.hostname is None:
33-
raise ValueError(
35+
raise EndpointResolutionError(
3436
f"Unable to parse hostname from provided URI: {params.uri}"
3537
)
3638

packages/smithy-http/src/smithy_http/endpoints.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
# SPDX-License-Identifier: Apache-2.0
33
from dataclasses import dataclass, field
44

5+
from smithy_core import SmithyException
56
from smithy_core.interfaces import URI
67

78
from . import Fields, interfaces
@@ -13,6 +14,10 @@ class Endpoint(interfaces.Endpoint):
1314
headers: interfaces.Fields = field(default_factory=Fields)
1415

1516

17+
class EndpointResolutionError(SmithyException):
18+
"""Exception type for all exceptions raised by endpoint resolution."""
19+
20+
1621
@dataclass
1722
class StaticEndpointParams:
1823
"""Static endpoint params.

0 commit comments

Comments
 (0)