send json response basic error
This commit is contained in:
parent
626a93a46c
commit
1ebba9f846
1 changed files with 2 additions and 2 deletions
|
|
@ -177,7 +177,7 @@ def register_exception_handlers(app: FastAPI):
|
||||||
etype, _, tb = sys.exc_info()
|
etype, _, tb = sys.exc_info()
|
||||||
traceback.print_exception(etype, err, tb)
|
traceback.print_exception(etype, err, tb)
|
||||||
exc = traceback.format_exc()
|
exc = traceback.format_exc()
|
||||||
|
|
||||||
if "text/html" in request.headers["accept"]:
|
if "text/html" in request.headers["accept"]:
|
||||||
return template_renderer().TemplateResponse(
|
return template_renderer().TemplateResponse(
|
||||||
"error.html", {"request": request, "err": err}
|
"error.html", {"request": request, "err": err}
|
||||||
|
|
@ -185,5 +185,5 @@ def register_exception_handlers(app: FastAPI):
|
||||||
|
|
||||||
return JSONResponse(
|
return JSONResponse(
|
||||||
status_code=HTTPStatus.NO_CONTENT,
|
status_code=HTTPStatus.NO_CONTENT,
|
||||||
content={"detail": exc.errors()},
|
content={"detail": exc},
|
||||||
)
|
)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue