feat: add headers support to HTTPException and auto-handle in router#1372
feat: add headers support to HTTPException and auto-handle in router#1372sansyrox wants to merge 1 commit into
Conversation
HTTPException now accepts an optional `headers` dict. When raised inside a route handler, the framework automatically catches it and returns the appropriate HTTP response — no manual `@app.exception` handler needed. Made-with: Cursor
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Warning Rate limit exceeded
Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 2 minutes and 13 seconds. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (4)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Summary
HTTPExceptionnow accepts an optionalheadersdict that gets included in the HTTP response when the exception is raised.HTTPExceptionhandling in the router: when a handler raisesHTTPException, the framework catches it and returns the correctResponsewith the appropriate status code, headers, and detail message — no manual@app.exceptionhandler needed.HTTPExceptionis now exported from the top-levelrobynpackage for convenient imports (from robyn import HTTPException).Changes
robyn/exceptions.pyheaders: dict | None = Noneparameter toHTTPException.__init__robyn/router.pyHTTPExceptioncatch block in bothasync_inner_handlerandinner_handler(before the genericExceptioncatch)robyn/__init__.pyHTTPExceptionto imports and__all__unit_tests/test_http_exception.py__str__, and__repr__Test plan
test_http_exception_default— verifies default detail from HTTP status phrase and empty headerstest_http_exception_custom_detail— verifies custom detail overridetest_http_exception_with_headers— verifies headers dict is stored and accessibletest_http_exception_str— verifies string representationtest_http_exception_repr— verifies repr contains class name and status codeMade with Cursor