Skip to content

Commit

Permalink
Fix: Handle no volume found instead of error 500
Browse files Browse the repository at this point in the history
  • Loading branch information
1yam committed Jul 16, 2024
1 parent 73438a4 commit 09b6d5b
Showing 1 changed file with 7 additions and 5 deletions.
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:
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})

0 comments on commit 09b6d5b

Please sign in to comment.