Skip to content

feat: Add custom exceptions#847

Open
Mr-Sunglasses wants to merge 9 commits into
sparckles:mainfrom
Mr-Sunglasses:fix/550
Open

feat: Add custom exceptions#847
Mr-Sunglasses wants to merge 9 commits into
sparckles:mainfrom
Mr-Sunglasses:fix/550

Conversation

@Mr-Sunglasses

Copy link
Copy Markdown
Contributor

Description

This PR fixes #550

@vercel

vercel Bot commented Jun 10, 2024

Copy link
Copy Markdown

@Mr-Sunglasses is attempting to deploy a commit to the sparckles Team on Vercel.

A member of the Team first needs to authorize it.

@Mr-Sunglasses

Copy link
Copy Markdown
Contributor Author

@sansyrox I've implemented custom HTTPException, take a look and please tell me if it is what we want to achieve in #550 😄

@codspeed-hq

codspeed-hq Bot commented Jun 10, 2024

Copy link
Copy Markdown

CodSpeed Performance Report

Merging #847 will not alter performance

Comparing Mr-Sunglasses:fix/550 (78a8a78) with main (862b764)

Summary

✅ 109 untouched benchmarks

Comment thread robyn/__init__.py
Comment thread robyn/exceptions.py Outdated
Comment thread robyn/reloader.py
Comment thread robyn/robyn.pyi
Comment thread robyn/ws.py

@sansyrox sansyrox left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Hey @Mr-Sunglasses ,

Thanks for the PR. I have some suggestions :D

@Mr-Sunglasses

Copy link
Copy Markdown
Contributor Author

Hey @Mr-Sunglasses ,

Thanks for the PR. I have some suggestions :D

Thanks, @sansyrox 🙏🏻, for the suggestions, I've fixed then 😄

@sansyrox

Copy link
Copy Markdown
Member

Hey @Mr-Sunglasses 👋

Could you please add some integration tests? And the CI is also failing for some reason.

Comment thread robyn/exceptions.py
class HTTPException(Exception):
def __init__(self, status_code: int, detail: str | None = None) -> None:
if detail is None:
detail = http.HTTPStatus(status_code).phrase

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The code attempts to create an HTTPStatus instance with an unchecked status_code, which can raise ValueError for invalid codes (like values above 599 or negative numbers). This exception is not caught, leading to unexpected behavior when an invalid status code is provided. The code should either validate the status_code range first or catch ValueError and provide a fallback message.

📚 Relevant Docs


React with 👍 to tell me that this comment was useful, or 👎 if not (and I'll stop posting more comments like this in the future)

@recurseml

recurseml Bot commented May 27, 2025

Copy link
Copy Markdown

😱 Found 1 issue. Time to roll up your sleeves! 😱

@sansyrox sansyrox left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for this, @Mr-Sunglasses, and apologies it sat so long. The landscape has shifted since you opened it: robyn/exceptions.py now already lives in main (it came in with the CORS PR #1019), which is why this is conflicting. That said, you've spotted a real gap — those exceptions still aren't exported from the top-level package, so from robyn import HTTPException doesn't actually work today. The most useful path forward would be to rebase and trim this down to just the export wiring in __init__.py (adding the import + the __all__ entries) plus your nice docs example, dropping the duplicate exceptions.py. Heads up that this also overlaps with #951, so let's coordinate to avoid double work — and a small test in test_exception_handling.py would seal it.

@sansyrox sansyrox added reviewed Reviewed by a maintainer duplicate This issue or pull request already exists labels Jun 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

duplicate This issue or pull request already exists reviewed Reviewed by a maintainer

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add custom exceptions in Robyn

2 participants