Skip to content

Commit 264f02a

Browse files
committed
Add new required method to codegen
1 parent 06ece22 commit 264f02a

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

codegen/core/src/main/java/software/amazon/smithy/python/codegen/HttpProtocolTestGenerator.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -619,6 +619,8 @@ private void writeUtilStubs(Symbol serviceSymbol) {
619619
writer.addImport("smithy_http", "tuples_to_fields");
620620
writer.addImport("smithy_http.aio", "HTTPResponse", "_HTTPResponse");
621621
writer.addImport("smithy_core.aio.utils", "async_list");
622+
writer.addImport("smithy_core.aio.interfaces", "ErrorInfo");
623+
writer.addStdlibImport("typing", "Any");
622624

623625
writer.write("""
624626
class $1L($2T):
@@ -634,6 +636,10 @@ class $3L:
634636
def __init__(self, *, client_config: HTTPClientConfiguration | None = None):
635637
self._client_config = client_config
636638
639+
def get_error_info(self, exception: Exception, **kwargs: Any) -> ErrorInfo:
640+
\"\"\"Get information about an exception.\"\"\"
641+
return ErrorInfo(is_timeout_error=False, fault="client")
642+
637643
async def send(
638644
self, request: HTTPRequest, *, request_config: HTTPRequestConfiguration | None = None
639645
) -> HTTPResponse:
@@ -657,6 +663,10 @@ def __init__(
657663
self.fields = tuples_to_fields(headers or [])
658664
self.body = body
659665
666+
def get_error_info(self, exception: Exception, **kwargs: Any) -> ErrorInfo:
667+
\"\"\"Get information about an exception.\"\"\"
668+
return ErrorInfo(is_timeout_error=False, fault="client")
669+
660670
async def send(
661671
self, request: HTTPRequest, *, request_config: HTTPRequestConfiguration | None = None
662672
) -> _HTTPResponse:

packages/smithy-http/tests/unit/aio/test_protocols.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,11 @@
88
from smithy_core import URI
99
from smithy_core.documents import TypeRegistry
1010
from smithy_core.endpoints import Endpoint
11+
from smithy_core.interfaces import TypedProperties
1112
from smithy_core.interfaces import URI as URIInterface
1213
from smithy_core.schemas import APIOperation
1314
from smithy_core.shapes import ShapeID
14-
from smithy_core.types import TypedProperties
15+
from smithy_core.types import TypedProperties as ConcreteTypedProperties
1516
from smithy_http import Fields
1617
from smithy_http.aio import HTTPRequest, HTTPResponse
1718
from smithy_http.aio.interfaces import HTTPRequest as HTTPRequestInterface
@@ -156,7 +157,7 @@ async def test_http_408_creates_timeout_error() -> None:
156157
response=response,
157158
response_body=b"",
158159
error_registry=TypeRegistry({}),
159-
context=TypedProperties(),
160+
context=ConcreteTypedProperties(),
160161
)
161162

162163
assert error.is_timeout_error is True

0 commit comments

Comments
 (0)