Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Handle no volume found instead of error 500 #581

Merged
merged 1 commit into from
Jul 25, 2024
Merged
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
12 changes: 7 additions & 5 deletions src/aleph/web/controllers/prices.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,13 @@ async def message_price(request: web.Request):
message = await get_executable_message(session, request.match_info["item_hash"])

content: ExecutableContent = message.parsed_content

if content.payment and content.payment.is_stream:
required_tokens = compute_flow_cost(session=session, content=content)
else:
required_tokens = compute_cost(session=session, content=content)
try:
if content.payment and content.payment.is_stream:
required_tokens = compute_flow_cost(session=session, content=content)
else:
required_tokens = compute_cost(session=session, content=content)
except RuntimeError as e:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you explain why is a RuntimeError error expected here ? Is that error not too generic ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where it can failed
It's in order to handle this error if volume is removed but not the program

raise web.HTTPNotFound(reason=str(e))

return web.json_response({"required_tokens": float(required_tokens),
"payment_type": content.payment.type if content.payment else None})
Loading