mirror of
https://github.com/lnbits/lnbits.git
synced 2025-03-28 18:52:00 +01:00
refactor: simplify condition (#2775)
This commit is contained in:
parent
09b1623bb0
commit
edfd297bf3
@ -26,11 +26,11 @@ class InvoiceError(Exception):
|
||||
def render_html_error(request: Request, exc: Exception) -> Optional[Response]:
|
||||
# Only the browser sends "text/html" request
|
||||
# not fail proof, but everything else get's a JSON response
|
||||
if (
|
||||
request.headers
|
||||
and "accept" in request.headers
|
||||
and "text/html" in request.headers["accept"]
|
||||
):
|
||||
if not request.headers:
|
||||
return None
|
||||
if "text/html" not in request.headers.get("accept", ""):
|
||||
return None
|
||||
|
||||
if (
|
||||
isinstance(exc, HTTPException)
|
||||
and exc.headers
|
||||
@ -52,8 +52,6 @@ def render_html_error(request: Request, exc: Exception) -> Optional[Response]:
|
||||
request, "error.html", {"err": f"Error: {exc!s}"}, status_code
|
||||
)
|
||||
|
||||
return None
|
||||
|
||||
|
||||
def register_exception_handlers(app: FastAPI):
|
||||
"""Register exception handlers for the FastAPI app"""
|
||||
|
Loading…
x
Reference in New Issue
Block a user