Add http error example
This commit is contained in:
+18
-2
@@ -1,7 +1,10 @@
|
||||
from fastapi import (
|
||||
APIRouter,
|
||||
status,
|
||||
Body, Depends)
|
||||
Body,
|
||||
Depends,
|
||||
HTTPException
|
||||
)
|
||||
from influxdb_client.client.influxdb_client_async import InfluxDBClientAsync
|
||||
from sqlalchemy.ext.asyncio import AsyncSession
|
||||
|
||||
@@ -62,4 +65,17 @@ async def get_mysql_by_id(id: int, db: AsyncSession = Depends(get_mysql_db)):
|
||||
execution_query = ExecutionQueryAsync(db)
|
||||
execution_model: list[ExecutionModel] = await execution_query.get_execution_by_id(id)
|
||||
res = [i.asdict() for i in execution_model]
|
||||
return {"results": res}
|
||||
return {"results": res}
|
||||
|
||||
@router.get(
|
||||
path="/get_error/{issue}",
|
||||
name='get error',
|
||||
responses={
|
||||
status.HTTP_401_UNAUTHORIZED: {},
|
||||
}
|
||||
)
|
||||
async def get_error(issue: bool = True):
|
||||
print(f"{issue=}")
|
||||
if issue:
|
||||
raise HTTPException(status_code=500, detail={'error':'b'})
|
||||
return True
|
||||
Reference in New Issue
Block a user