mirror of
https://github.com/lnbits/lnbits.git
synced 2025-10-11 04:52:34 +02:00
Merge pull request #1198 from lnbits/fix/error_handling/httpexception_no_stacktrace
Fix/error_handling/httpexception_no_stacktrace
This commit is contained in:
@@ -174,6 +174,8 @@ def register_exception_handlers(app: FastAPI):
|
|||||||
etype, _, tb = sys.exc_info()
|
etype, _, tb = sys.exc_info()
|
||||||
traceback.print_exception(etype, exc, tb)
|
traceback.print_exception(etype, exc, tb)
|
||||||
logger.error(f"Exception: {str(exc)}")
|
logger.error(f"Exception: {str(exc)}")
|
||||||
|
# Only the browser sends "text/html" request
|
||||||
|
# not fail proof, but everything else get's a JSON response
|
||||||
if (
|
if (
|
||||||
request.headers
|
request.headers
|
||||||
and "accept" in request.headers
|
and "accept" in request.headers
|
||||||
@@ -192,8 +194,6 @@ def register_exception_handlers(app: FastAPI):
|
|||||||
async def validation_exception_handler(
|
async def validation_exception_handler(
|
||||||
request: Request, exc: RequestValidationError
|
request: Request, exc: RequestValidationError
|
||||||
):
|
):
|
||||||
etype, _, tb = sys.exc_info()
|
|
||||||
traceback.print_exception(etype, exc, tb)
|
|
||||||
logger.error(f"RequestValidationError: {str(exc)}")
|
logger.error(f"RequestValidationError: {str(exc)}")
|
||||||
# Only the browser sends "text/html" request
|
# Only the browser sends "text/html" request
|
||||||
# not fail proof, but everything else get's a JSON response
|
# not fail proof, but everything else get's a JSON response
|
||||||
@@ -215,8 +215,6 @@ def register_exception_handlers(app: FastAPI):
|
|||||||
|
|
||||||
@app.exception_handler(HTTPException)
|
@app.exception_handler(HTTPException)
|
||||||
async def http_exception_handler(request: Request, exc: HTTPException):
|
async def http_exception_handler(request: Request, exc: HTTPException):
|
||||||
etype, _, tb = sys.exc_info()
|
|
||||||
traceback.print_exception(etype, exc, tb)
|
|
||||||
logger.error(f"HTTPException {exc.status_code}: {exc.detail}")
|
logger.error(f"HTTPException {exc.status_code}: {exc.detail}")
|
||||||
# Only the browser sends "text/html" request
|
# Only the browser sends "text/html" request
|
||||||
# not fail proof, but everything else get's a JSON response
|
# not fail proof, but everything else get's a JSON response
|
||||||
|
Reference in New Issue
Block a user