Coverage for polar/oauth2/exception_handlers.py: 91%

9 statements  

« prev     ^ index     » next       coverage.py v7.15.2, created at 2026-10-07 12:42 +0000

1import json 

2 

3from authlib.oauth2 import OAuth2Error 

4from fastapi import Request, Response 

5 

6 

7async def oauth2_error_exception_handler( 

8 request: Request, exc: OAuth2Error 

9) -> Response: 

10 status_code, body, headers = exc() 

11 if isinstance(body, dict): 11 ↛ 13line 11 didn't jump to line 13 because the condition on line 11 was always true

12 body = json.dumps(body) 

13 return Response(body, status_code=status_code, headers={k: v for k, v in headers}) 

14 

15 

16__all__ = ["oauth2_error_exception_handler", "OAuth2Error"]