Enable DEBUG logging and add global exception handler for 500s
This commit is contained in:
+2
-1
@@ -8,6 +8,7 @@ RUN pip install --no-cache-dir -r requirements.txt
|
||||
COPY server.py .
|
||||
|
||||
ENV PORT=8000
|
||||
ENV LOG_LEVEL=DEBUG
|
||||
EXPOSE 8000
|
||||
|
||||
CMD ["uvicorn", "server:app", "--host", "0.0.0.0", "--port", "8000"]
|
||||
CMD ["uvicorn", "server:app", "--host", "0.0.0.0", "--port", "8000", "--log-level", "debug"]
|
||||
|
||||
@@ -970,6 +970,12 @@ app = FastAPI(
|
||||
version="1.0.0",
|
||||
)
|
||||
|
||||
|
||||
@app.exception_handler(Exception)
|
||||
async def global_exception_handler(request, exc):
|
||||
logger.exception("Unhandled exception")
|
||||
raise HTTPException(status_code=500, detail="Internal server error")
|
||||
|
||||
# Request models
|
||||
|
||||
class ListFoldersRequest(BaseModel):
|
||||
|
||||
Reference in New Issue
Block a user