Skip to content

Commit fc5a15e

Browse files
Alex Wangyaythomas
authored andcommitted
fix: use CallbackError for non-successful callback
1 parent a77264c commit fc5a15e

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

src/aws_durable_execution_sdk_python/context.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,15 +182,20 @@ def result(self) -> T | None:
182182

183183
if not checkpointed_result.is_existent():
184184
msg = "Callback operation must exist"
185-
raise CallbackError(msg)
185+
raise CallbackError(message=msg, callback_id=self.callback_id)
186186

187187
if (
188188
checkpointed_result.is_failed()
189189
or checkpointed_result.is_cancelled()
190190
or checkpointed_result.is_timed_out()
191191
or checkpointed_result.is_stopped()
192192
):
193-
checkpointed_result.raise_callable_error()
193+
msg = (
194+
checkpointed_result.error.message
195+
if checkpointed_result.error and checkpointed_result.error.message
196+
else "Callback failed"
197+
)
198+
raise CallbackError(message=msg, callback_id=self.callback_id)
194199

195200
if checkpointed_result.is_succeeded():
196201
if checkpointed_result.result is None:

tests/context_test.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
)
1919
from aws_durable_execution_sdk_python.context import Callback, DurableContext
2020
from aws_durable_execution_sdk_python.exceptions import (
21-
CallableRuntimeError,
2221
CallbackError,
2322
SuspendExecution,
2423
ValidationError,
@@ -172,7 +171,7 @@ def test_callback_result_failed():
172171

173172
callback = Callback("callback5", "op5", mock_state)
174173

175-
with pytest.raises(CallableRuntimeError):
174+
with pytest.raises(CallbackError):
176175
callback.result()
177176

178177

@@ -231,7 +230,7 @@ def test_callback_result_timed_out():
231230

232231
callback = Callback("callback_timeout", "op_timeout", mock_state)
233232

234-
with pytest.raises(CallableRuntimeError):
233+
with pytest.raises(CallbackError):
235234
callback.result()
236235

237236

0 commit comments

Comments
 (0)