Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions src/aws_durable_execution_sdk_python/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,15 +182,20 @@ def result(self) -> T | None:

if not checkpointed_result.is_existent():
msg = "Callback operation must exist"
raise CallbackError(msg)
raise CallbackError(message=msg, callback_id=self.callback_id)

if (
checkpointed_result.is_failed()
or checkpointed_result.is_cancelled()
or checkpointed_result.is_timed_out()
or checkpointed_result.is_stopped()
):
checkpointed_result.raise_callable_error()
msg = (
checkpointed_result.error.message
if checkpointed_result.error and checkpointed_result.error.message
else "Callback failed"
)
raise CallbackError(message=msg, callback_id=self.callback_id)

if checkpointed_result.is_succeeded():
if checkpointed_result.result is None:
Expand Down
5 changes: 2 additions & 3 deletions tests/context_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
)
from aws_durable_execution_sdk_python.context import Callback, DurableContext
from aws_durable_execution_sdk_python.exceptions import (
CallableRuntimeError,
CallbackError,
SuspendExecution,
ValidationError,
Expand Down Expand Up @@ -172,7 +171,7 @@ def test_callback_result_failed():

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

with pytest.raises(CallableRuntimeError):
with pytest.raises(CallbackError):
callback.result()


Expand Down Expand Up @@ -231,7 +230,7 @@ def test_callback_result_timed_out():

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

with pytest.raises(CallableRuntimeError):
with pytest.raises(CallbackError):
callback.result()


Expand Down