Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions core/nurse_scheduling/serve.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
from fastapi.responses import StreamingResponse
from fastapi.middleware.cors import CORSMiddleware
from pydantic import ValidationError
from ruamel.yaml import YAMLError
from . import scheduler, exporter


Expand Down Expand Up @@ -177,6 +178,10 @@ async def optimize_and_export_xlsx(
# User-supplied scheduling data failed schema validation -> HTTP 400
logging.error(f"Invalid scheduling data: {str(e)}")
raise HTTPException(status_code=400, detail=f"Invalid scheduling data: {str(e)}")
except YAMLError as e:
# User-supplied YAML failed to parse -> HTTP 400 (not an internal server error)
logging.warning(f"Invalid YAML: {str(e)}")
raise HTTPException(status_code=400, detail=f"Invalid YAML: {str(e)}")
except Exception as e:
# TODO(security): Returning the error message to the client may be a security risk
logging.error(f"Error during optimization: {str(e)}")
Expand Down
Loading