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

Add custom exceptions in Robyn #550

Open
sansyrox opened this issue Jul 12, 2023 · 2 comments · May be fixed by #847
Open

Add custom exceptions in Robyn #550

sansyrox opened this issue Jul 12, 2023 · 2 comments · May be fixed by #847
Labels
enhancement New feature or request

Comments

@sansyrox
Copy link
Member

There are many exceptions in Web that are recurring. We should be exposing them so that the developers don't have redo the task again and again

@sansyrox sansyrox added the enhancement New feature or request label Jul 12, 2023
@Mr-Sunglasses
Copy link
Contributor

Hey @sansyrox, Do you mean something like this while referring to custom exceptions

from robyn import Robyn, HTTPException

app = Robyn(__file__)

items = {"foo": "The Foo Wrestlers"}


@app.get("/items/{item_id}")
async def read_item(request, item_id: str):
    if item_id not in items:
        raise HTTPException(status_code=404, detail="Item not found")
    return {"item": items[item_id]}

@sansyrox
Copy link
Member Author

sansyrox commented Jun 9, 2024

Hey @Mr-Sunglasses , yes!

@Mr-Sunglasses Mr-Sunglasses linked a pull request Jun 10, 2024 that will close this issue
@sansyrox sansyrox pinned this issue Aug 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants