Skip to content
This repository has been archived by the owner on Mar 1, 2024. It is now read-only.

Commit

Permalink
Merge branch 'main' into ykeremy/polars-perf-upgrade
Browse files Browse the repository at this point in the history
  • Loading branch information
ykeremy committed Oct 6, 2023
2 parents 5e68fef + 99571b8 commit fa73bf5
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
4 changes: 4 additions & 0 deletions wyvern/components/events/events.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,10 @@ class EntityEventData(BaseModel):
entity_identifier_type: str


class CustomEntityEventData(EntityEventData):
event_name: str


ENTITY_EVENT_DATA_TYPE = TypeVar("ENTITY_EVENT_DATA_TYPE", bound=EntityEventData)


Expand Down
19 changes: 9 additions & 10 deletions wyvern/web_frameworks/fastapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,16 +72,6 @@ def __init__(self, host: str = "127.0.0.1", port: int = 8000) -> None:
self.host = host
self.port = port

@self.app.exception_handler(WyvernError)
async def wyvern_exception_handler(request: Request, exc: WyvernError):
return JSONResponse(
status_code=400,
content={
"detail": str(exc),
"error_code": exc.error_code,
},
)

@self.app.get("/healthcheck")
async def healthcheck() -> Dict[str, str]:
return {"status": "OK"}
Expand Down Expand Up @@ -181,6 +171,15 @@ async def post(
except ValidationError as e:
logger.exception(f"Validation error error={e} request_payload={json}")
raise HTTPException(status_code=422, detail=e.errors())
except WyvernError as e:
logger.warning(f"Wyvern error error={e} request_payload={json}")
return JSONResponse(
status_code=400,
content={
"detail": str(e),
"error_code": e.error_code,
},
)
except Exception as e:
logger.exception(f"Unexpected error error={e} request_payload={json}")
raise HTTPException(status_code=500, detail=str(e))
Expand Down

0 comments on commit fa73bf5

Please sign in to comment.