Skip to content

Commit

Permalink
Improve error messages for accessing the result of a graph run before…
Browse files Browse the repository at this point in the history
… it has finished
  • Loading branch information
dmontagu committed Feb 6, 2025
1 parent e4d384a commit aa74a7c
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion pydantic_graph/pydantic_graph/graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -542,7 +542,15 @@ def is_ended(self):
@property
def result(self) -> RunEndT:
if self._result is None:
raise exceptions.GraphRuntimeError('GraphRun has not ended yet.')
if self._started:
raise exceptions.GraphRuntimeError(
'This GraphRun has not yet ended. Continue iterating with `async for` or `GraphRun.next`'
' to complete the run before accessing the result.'
)
else:
raise exceptions.GraphRuntimeError(
'This GraphRun has not been started. Did you forget to `await` the run?'
)
return self._result.data

async def next(
Expand Down

0 comments on commit aa74a7c

Please sign in to comment.