Skip to content

Commit 7fcec38

Browse files
Move error retry info to retries interfaces
1 parent a493125 commit 7fcec38

File tree

3 files changed

+29
-27
lines changed

3 files changed

+29
-27
lines changed

designs/exceptions.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ implement.
4040
```python
4141
@dataclass(kw_only=True)
4242
@runtime_checkable
43-
class RetryInfo(Protocol):
43+
class ErrorRetryInfo(Protocol):
4444
is_retry_safe: bool | None = None
4545
"""Whether the exception is safe to retry.
4646

packages/smithy-core/src/smithy_core/exceptions.py

Lines changed: 2 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
22
# SPDX-License-Identifier: Apache-2.0
33
from dataclasses import dataclass, field
4-
from typing import Literal, Protocol, runtime_checkable
4+
from typing import Literal
55

66

77
class SmithyException(Exception):
@@ -16,30 +16,7 @@ class SmithyException(Exception):
1616

1717

1818
@dataclass(kw_only=True)
19-
@runtime_checkable
20-
class RetryInfo(Protocol):
21-
is_retry_safe: bool | None = None
22-
"""Whether the exception is safe to retry.
23-
24-
A value of True does not mean a retry will occur, but rather that a retry is allowed
25-
to occur.
26-
27-
A value of None indicates that there is not enough information available to
28-
determine if a retry is safe.
29-
"""
30-
31-
retry_after: float | None = None
32-
"""The amount of time that should pass before a retry.
33-
34-
Retry strategies MAY choose to wait longer.
35-
"""
36-
37-
is_throttle: bool = False
38-
"""Whether the error is a throttling error."""
39-
40-
41-
@dataclass(kw_only=True)
42-
class CallException(SmithyException, RetryInfo):
19+
class CallException(SmithyException):
4320
"""Base exception to be used in application-level errors."""
4421

4522
fault: Fault = None

packages/smithy-core/src/smithy_core/interfaces/retries.py

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,32 @@
22
# SPDX-License-Identifier: Apache-2.0
33
from dataclasses import dataclass
44
from enum import Enum
5-
from typing import Protocol
5+
from typing import Protocol, runtime_checkable
6+
7+
8+
@dataclass(kw_only=True)
9+
@runtime_checkable
10+
class ErrorRetryInfo(Protocol):
11+
"""A protocol for exceptions that have retry information embedded."""
12+
13+
is_retry_safe: bool | None = None
14+
"""Whether the exception is safe to retry.
15+
16+
A value of True does not mean a retry will occur, but rather that a retry is allowed
17+
to occur.
18+
19+
A value of None indicates that there is not enough information available to
20+
determine if a retry is safe.
21+
"""
22+
23+
retry_after: float | None = None
24+
"""The amount of time that should pass before a retry.
25+
26+
Retry strategies MAY choose to wait longer.
27+
"""
28+
29+
is_throttle: bool = False
30+
"""Whether the error is a throttling error."""
631

732

833
class RetryErrorType(Enum):

0 commit comments

Comments
 (0)