Skip to content

Commit

Permalink
feat: FastAPI Exception Handler μΆ”κ°€
Browse files Browse the repository at this point in the history
μ—λŸ¬ λ°œμƒμ‹œ λŒ€λž΅μ μœΌλ‘œ μ–΄λ–€ μ—λŸ¬μΈμ§€ λ©”μ‹œμ§€ 리턴
  • Loading branch information
ganghe74 committed Jan 30, 2023
1 parent 12cecb8 commit aad1c03
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/backend/main.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
from fastapi import FastAPI
from fastapi.responses import JSONResponse
from fastapi.middleware.cors import CORSMiddleware
from backend.routers import txt_extraction, machine_translation, untypical_txt_extraction, untypical_machine_translation, untypical_generation
from backend.routers import (
txt_extraction,
machine_translation,
untypical_txt_extraction,
untypical_machine_translation,
untypical_generation,
)

app = FastAPI()

Expand All @@ -20,3 +27,8 @@
app.include_router(untypical_txt_extraction.router)
app.include_router(untypical_machine_translation.router)
app.include_router(untypical_generation.router)


@app.exception_handler(Exception)
async def exception_handler(request, exc):
return JSONResponse(status_code=500, content={"message": str(exc)})

0 comments on commit aad1c03

Please # to comment.