Robyn
Robyn copied to clipboard
If i raise a exceptions and Robyn will not handle them
Bug Description
I tried to add a handle_exception as per the documentation, but nothing worked.
Steps to Reproduce
@app.exception
def handle_exception(error):
return {"status_code": 500, "body": f"error msg: {error}"}
@app.get("/")
async def hello(request):
raise BaseException("BaseException")
return jsonify({"message": "Hello World"})
If I send a request to this URL directly, I just get "Internal server error".
Your operating system
MacOS
Your Python version (python --version)
3.11
Your Robyn version
latest
Additional Info
No response
Hey @T-baby 👋
Thank you for raising an issue. But there is an issue with the code. You should never raise a BaseException, as it serves as the base class for all the other exceptions. You should raise an Exception or better a specific exception in your code. I hope this helps 😄
Let me know if you have any more questions 😄
How can we handle 404 status when a route is not defined?I tried to use after_request interception is feasible, is there any other better solution?