update APIException
This commit is contained in:
@@ -294,7 +294,7 @@ async def test(file:UploadFile= File(...),app:str=None):
|
|||||||
# kintone = getfieldsfromkintone(app)
|
# kintone = getfieldsfromkintone(app)
|
||||||
# fields = analysefields(excel,kintone["properties"])
|
# fields = analysefields(excel,kintone["properties"])
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
raise HTTPException(status_code=400, detail=f"Error occurred while parsing file {file.filename}: {str(e)}")
|
raise HTTPException(status_code=400, detail=f"Error occurred while parsing file {file.filename}")
|
||||||
else:
|
else:
|
||||||
raise HTTPException(status_code=400, detail=f"File {file.filename} is not an Excel file")
|
raise HTTPException(status_code=400, detail=f"File {file.filename} is not an Excel file")
|
||||||
|
|
||||||
@@ -310,7 +310,7 @@ async def download(request:Request,key,c:config.KINTONE_ENV=Depends(getkintoneen
|
|||||||
r = httpx.get(url,headers=headers,params=params)
|
r = httpx.get(url,headers=headers,params=params)
|
||||||
return r.json()
|
return r.json()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
raise APIException('kintone:upload',request.url._url,f"Error occurred while download file.json: {str(e)}")
|
raise APIException('kintone:upload',request.url._url,f"Error occurred while download file.json:",e)
|
||||||
|
|
||||||
@r.post("/upload")
|
@r.post("/upload")
|
||||||
async def upload(request:Request,files:t.List[UploadFile] = File(...)):
|
async def upload(request:Request,files:t.List[UploadFile] = File(...)):
|
||||||
@@ -323,9 +323,9 @@ async def upload(request:Request,files:t.List[UploadFile] = File(...)):
|
|||||||
print(df)
|
print(df)
|
||||||
dataframes.append(df)
|
dataframes.append(df)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
raise APIException('kintone:upload',request.url._url,f"Error occurred while uploading file {file.filename}: {str(e)}")
|
raise APIException('kintone:upload',request.url._url,f"Error occurred while uploading file {file.filename}:",e)
|
||||||
else:
|
else:
|
||||||
raise APIException('kintone:upload',request.url._url, detail=f"File {file.filename} is not an Excel file")
|
raise APIException('kintone:upload',request.url._url, f"File {file.filename} is not an Excel file",e)
|
||||||
|
|
||||||
return {"files": [file.filename for file in files]}
|
return {"files": [file.filename for file in files]}
|
||||||
|
|
||||||
@@ -348,7 +348,7 @@ async def jscss(request:Request,app:str,files:t.List[UploadFile] = File(...),env
|
|||||||
deoployappfromkintone(app,appjscs["revision"],env)
|
deoployappfromkintone(app,appjscs["revision"],env)
|
||||||
return appjscs
|
return appjscs
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
raise APIException('kintone:updatejscss',request.url._url, detail=f"Error occurred while update js/css {file.filename} is not an Excel file")
|
raise APIException('kintone:updatejscss',request.url._url, f"Error occurred while update js/css {file.filename} is not an Excel file",e)
|
||||||
|
|
||||||
@r.get("/app")
|
@r.get("/app")
|
||||||
async def app(request:Request,app:str,c:config.KINTONE_ENV=Depends(getkintoneenv)):
|
async def app(request:Request,app:str,c:config.KINTONE_ENV=Depends(getkintoneenv)):
|
||||||
@@ -359,7 +359,7 @@ async def app(request:Request,app:str,c:config.KINTONE_ENV=Depends(getkintoneenv
|
|||||||
r = httpx.get(url,headers=headers,params=params)
|
r = httpx.get(url,headers=headers,params=params)
|
||||||
return r.json()
|
return r.json()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
raise APIException('kintone:app',request.url._url, detail=f"Error occurred while get app({c.DOMAIN_NAM}->{app}) : {str(e)}")
|
raise APIException('kintone:app',request.url._url, f"Error occurred while get app({c.DOMAIN_NAM}->{app}):",e)
|
||||||
|
|
||||||
@r.get("/allapps")
|
@r.get("/allapps")
|
||||||
async def allapps(request:Request,c:config.KINTONE_ENV=Depends(getkintoneenv)):
|
async def allapps(request:Request,c:config.KINTONE_ENV=Depends(getkintoneenv)):
|
||||||
@@ -369,21 +369,21 @@ async def allapps(request:Request,c:config.KINTONE_ENV=Depends(getkintoneenv)):
|
|||||||
r = httpx.get(url,headers=headers)
|
r = httpx.get(url,headers=headers)
|
||||||
return r.json()
|
return r.json()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
raise APIException('kintone:allapps',request.url._url, detail=f"Error occurred while get allapps({c.DOMAIN_NAM}) : {str(e)}")
|
raise APIException('kintone:allapps',request.url._url, f"Error occurred while get allapps({c.DOMAIN_NAM}):",e)
|
||||||
|
|
||||||
@r.get("/appfields")
|
@r.get("/appfields")
|
||||||
async def appfields(request:Request,app:str,env = Depends(getkintoneenv)):
|
async def appfields(request:Request,app:str,env = Depends(getkintoneenv)):
|
||||||
try:
|
try:
|
||||||
return getfieldsfromkintone(app,env)
|
return getfieldsfromkintone(app,env)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
raise APIException('kintone:appfields',request.url._url, detail=f"Error occurred while get app fileds({env.DOMAIN_NAM}->{app}) : {str(e)}")
|
raise APIException('kintone:appfields',request.url._url, f"Error occurred while get app fileds({env.DOMAIN_NAM}->{app}):",e)
|
||||||
|
|
||||||
@r.get("/appprocess")
|
@r.get("/appprocess")
|
||||||
async def appprocess(request:Request,app:str,env = Depends(getkintoneenv)):
|
async def appprocess(request:Request,app:str,env = Depends(getkintoneenv)):
|
||||||
try:
|
try:
|
||||||
return getprocessfromkintone(app,env)
|
return getprocessfromkintone(app,env)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
raise APIException('kintone:appprocess',request.url._url, detail=f"Error occurred while get app process({env.DOMAIN_NAM}->{app}) : {str(e)}")
|
raise APIException('kintone:appprocess',request.url._url, f"Error occurred while get app process({env.DOMAIN_NAM}->{app}):",e)
|
||||||
|
|
||||||
@r.get("/alljscss")
|
@r.get("/alljscss")
|
||||||
async def alljscs(request:Request,app:str,c:config.KINTONE_ENV=Depends(getkintoneenv)):
|
async def alljscs(request:Request,app:str,c:config.KINTONE_ENV=Depends(getkintoneenv)):
|
||||||
@@ -394,7 +394,7 @@ async def alljscs(request:Request,app:str,c:config.KINTONE_ENV=Depends(getkinton
|
|||||||
r = httpx.get(url,headers=headers,params=params)
|
r = httpx.get(url,headers=headers,params=params)
|
||||||
return r.json()
|
return r.json()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
raise APIException('kintone:alljscss',request.url._url, detail=f"Error occurred while get app js/css({c.DOMAIN_NAM}->{app}) : {str(e)}")
|
raise APIException('kintone:alljscss',request.url._url, f"Error occurred while get app js/css({c.DOMAIN_NAM}->{app}):",e)
|
||||||
|
|
||||||
@r.post("/createapp",)
|
@r.post("/createapp",)
|
||||||
async def createapp(request:Request,name:str,c:config.KINTONE_ENV=Depends(getkintoneenv)):
|
async def createapp(request:Request,name:str,c:config.KINTONE_ENV=Depends(getkintoneenv)):
|
||||||
@@ -410,7 +410,7 @@ async def createapp(request:Request,name:str,c:config.KINTONE_ENV=Depends(getkin
|
|||||||
r = httpx.post(url,headers=headers,data=json.dumps(data))
|
r = httpx.post(url,headers=headers,data=json.dumps(data))
|
||||||
return r.json
|
return r.json
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
raise APIException('kintone:createapp',request.url._url, detail=f"Error occurred while create app({c.DOMAIN_NAM}->{name}) : {str(e)}")
|
raise APIException('kintone:createapp',request.url._url, f"Error occurred while create app({c.DOMAIN_NAM}->{name}):",e)
|
||||||
|
|
||||||
property=["label","code","type","required","defaultValue","options"]
|
property=["label","code","type","required","defaultValue","options"]
|
||||||
|
|
||||||
@@ -442,9 +442,9 @@ async def createappfromexcel(request:Request,files:t.List[UploadFile] = File(...
|
|||||||
result["revision"] = app["revision"]
|
result["revision"] = app["revision"]
|
||||||
deoployappfromkintone(result["app"],result["revision"],env)
|
deoployappfromkintone(result["app"],result["revision"],env)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
raise APIException('kintone:createappfromexcel',request.url._url, detail=f"Error occurred while parsing file ({env.DOMAIN_NAM}->{file.filename}) : {str(e)}")
|
raise APIException('kintone:createappfromexcel',request.url._url, f"Error occurred while parsing file ({env.DOMAIN_NAM}->{file.filename}):",e)
|
||||||
else:
|
else:
|
||||||
raise APIException('kintone:createappfromexcel',request.url._url, detail=f"File {file.filename} is not an Excel file")
|
raise APIException('kintone:createappfromexcel',request.url._url, f"File {file.filename} is not an Excel file",e)
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
|
||||||
@@ -493,9 +493,9 @@ async def updateappfromexcel(request:Request,app:str,files:t.List[UploadFile] =
|
|||||||
if deploy:
|
if deploy:
|
||||||
result = deoployappfromkintone(app,revision,env)
|
result = deoployappfromkintone(app,revision,env)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
raise APIException('kintone:updateappfromexcel',request.url._url, detail=f"Error occurred while parsing file ({env.DOMAIN_NAM}->{file.filename}) : {str(e)}")
|
raise APIException('kintone:updateappfromexcel',request.url._url, f"Error occurred while parsing file ({env.DOMAIN_NAM}->{file.filename}):",e)
|
||||||
else:
|
else:
|
||||||
raise APIException('kintone:updateappfromexcel',request.url._url, detail=f"File {file.filename} is not an Excel file")
|
raise APIException('kintone:updateappfromexcel',request.url._url, f"File {file.filename} is not an Excel file",e)
|
||||||
return result
|
return result
|
||||||
|
|
||||||
@r.post("/updateprocessfromexcel",)
|
@r.post("/updateprocessfromexcel",)
|
||||||
@@ -530,7 +530,7 @@ async def updateprocessfromexcel(request:Request,app:str,env = Depends(getkinton
|
|||||||
if deploy:
|
if deploy:
|
||||||
result = deoployappfromkintone(app,revision,env)
|
result = deoployappfromkintone(app,revision,env)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
raise APIException('kintone:updateprocessfromexcel',request.url._url, detail=f"Error occurred while update process ({env.DOMAIN_NAM}->{app}) : {str(e)}")
|
raise APIException('kintone:updateprocessfromexcel',request.url._url, f"Error occurred while update process ({env.DOMAIN_NAM}->{app}):",e)
|
||||||
|
|
||||||
return result
|
return result
|
||||||
|
|
||||||
@@ -551,4 +551,4 @@ async def createjstokintone(request:Request,app:str,env:config.KINTONE_ENV = Dep
|
|||||||
deoployappfromkintone(app,appjscs["revision"],env)
|
deoployappfromkintone(app,appjscs["revision"],env)
|
||||||
return appjscs
|
return appjscs
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
raise APIException('kintone:createjstokintone',request.url._url, detail=f"Error occurred while create js ({env.DOMAIN_NAM}->{app}) : {str(e)}")
|
raise APIException('kintone:createjstokintone',request.url._url, f"Error occurred while create js ({env.DOMAIN_NAM}->{app}):",e)
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ async def appsetting_details(
|
|||||||
app = get_appsetting(db, id)
|
app = get_appsetting(db, id)
|
||||||
return app
|
return app
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
raise APIException('platform:appsettings',request.url._url,f"Error occurred while get app setting: {str(e)}")
|
raise APIException('platform:appsettings',request.url._url,f"Error occurred while get app setting:",e)
|
||||||
|
|
||||||
@r.post("/appsettings", response_model=App, response_model_exclude_none=True)
|
@r.post("/appsettings", response_model=App, response_model_exclude_none=True)
|
||||||
async def appsetting_create(
|
async def appsetting_create(
|
||||||
@@ -34,7 +34,7 @@ async def appsetting_create(
|
|||||||
try:
|
try:
|
||||||
return create_appsetting(db, app)
|
return create_appsetting(db, app)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
raise APIException('platform:appsettings',request.url._url,f"Error occurred while get create app setting: {str(e)}")
|
raise APIException('platform:appsettings',request.url._url,f"Error occurred while get create app setting:",e)
|
||||||
|
|
||||||
|
|
||||||
@r.put(
|
@r.put(
|
||||||
@@ -49,7 +49,7 @@ async def appsetting_edit(
|
|||||||
try:
|
try:
|
||||||
return edit_appsetting(db, id, app)
|
return edit_appsetting(db, id, app)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
raise APIException('platform:appsettings',request.url._url,f"Error occurred while edit app setting: {str(e)}")
|
raise APIException('platform:appsettings',request.url._url,f"Error occurred while edit app setting:",e)
|
||||||
|
|
||||||
|
|
||||||
@r.delete(
|
@r.delete(
|
||||||
@@ -63,7 +63,7 @@ async def appsettings_delete(
|
|||||||
try:
|
try:
|
||||||
return delete_appsetting(db, id)
|
return delete_appsetting(db, id)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
raise APIException('platform:appsettings',request.url._url,f"Error occurred while delete app setting: {str(e)}")
|
raise APIException('platform:appsettings',request.url._url,f"Error occurred while delete app setting:",e)
|
||||||
|
|
||||||
|
|
||||||
@r.get(
|
@r.get(
|
||||||
@@ -80,7 +80,7 @@ async def kintone_data(
|
|||||||
kintone = get_kintones(db, type)
|
kintone = get_kintones(db, type)
|
||||||
return kintone
|
return kintone
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
raise APIException('platform:kintone',request.url._url,f"Error occurred while get kintone env: {str(e)}")
|
raise APIException('platform:kintone',request.url._url,f"Error occurred while get kintone env:",e)
|
||||||
|
|
||||||
@r.get(
|
@r.get(
|
||||||
"/actions",
|
"/actions",
|
||||||
@@ -96,7 +96,7 @@ async def action_data(
|
|||||||
actions = get_actions(db)
|
actions = get_actions(db)
|
||||||
return actions
|
return actions
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
raise APIException('platform:actions',request.url._url,f"Error occurred while get actions: {str(e)}")
|
raise APIException('platform:actions',request.url._url,f"Error occurred while get actions:",e)
|
||||||
|
|
||||||
@r.get(
|
@r.get(
|
||||||
"/flow/{flowid}",
|
"/flow/{flowid}",
|
||||||
@@ -112,7 +112,7 @@ async def flow_details(
|
|||||||
app = get_flow(db, flowid)
|
app = get_flow(db, flowid)
|
||||||
return app
|
return app
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
raise APIException('platform:flow',request.url._url,f"Error occurred while get flow by flowid: {str(e)}")
|
raise APIException('platform:flow',request.url._url,f"Error occurred while get flow by flowid:",e)
|
||||||
|
|
||||||
|
|
||||||
@r.get(
|
@r.get(
|
||||||
@@ -132,7 +132,7 @@ async def flow_list(
|
|||||||
flows = get_flows_by_app(db, domain.id, appid)
|
flows = get_flows_by_app(db, domain.id, appid)
|
||||||
return flows
|
return flows
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
raise APIException('platform:flow',request.url._url,f"Error occurred while get flow by appid: {str(e)}")
|
raise APIException('platform:flow',request.url._url,f"Error occurred while get flow by appid:",e)
|
||||||
|
|
||||||
|
|
||||||
@r.post("/flow", response_model=Flow, response_model_exclude_none=True)
|
@r.post("/flow", response_model=Flow, response_model_exclude_none=True)
|
||||||
@@ -146,7 +146,7 @@ async def flow_create(
|
|||||||
domain = get_activedomain(db, user.id)
|
domain = get_activedomain(db, user.id)
|
||||||
return create_flow(db, domain.id, flow)
|
return create_flow(db, domain.id, flow)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
raise APIException('platform:flow',request.url._url,f"Error occurred while create flow: {str(e)}")
|
raise APIException('platform:flow',request.url._url,f"Error occurred while create flow:",e)
|
||||||
|
|
||||||
|
|
||||||
@r.put(
|
@r.put(
|
||||||
@@ -160,7 +160,7 @@ async def flow_edit(
|
|||||||
try:
|
try:
|
||||||
return edit_flow(db, flow)
|
return edit_flow(db, flow)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
raise APIException('platform:flow',request.url._url,f"Error occurred while edit flow: {str(e)}")
|
raise APIException('platform:flow',request.url._url,f"Error occurred while edit flow:",e)
|
||||||
|
|
||||||
|
|
||||||
@r.delete(
|
@r.delete(
|
||||||
@@ -174,7 +174,7 @@ async def flow_delete(
|
|||||||
try:
|
try:
|
||||||
return delete_flow(db, flowid)
|
return delete_flow(db, flowid)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
raise APIException('platform:flow',request.url._url,f"Error occurred while delete flow: {str(e)}")
|
raise APIException('platform:flow',request.url._url,f"Error occurred while delete flow:",e)
|
||||||
|
|
||||||
@r.get(
|
@r.get(
|
||||||
"/domains/{tenantid}",
|
"/domains/{tenantid}",
|
||||||
@@ -190,7 +190,7 @@ async def domain_details(
|
|||||||
domains = get_domains(db,tenantid)
|
domains = get_domains(db,tenantid)
|
||||||
return domains
|
return domains
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
raise APIException('platform:domains',request.url._url,f"Error occurred while get domains: {str(e)}")
|
raise APIException('platform:domains',request.url._url,f"Error occurred while get domains:",e)
|
||||||
|
|
||||||
@r.post("/domain", response_model=Domain, response_model_exclude_none=True)
|
@r.post("/domain", response_model=Domain, response_model_exclude_none=True)
|
||||||
async def domain_create(
|
async def domain_create(
|
||||||
@@ -201,7 +201,7 @@ async def domain_create(
|
|||||||
try:
|
try:
|
||||||
return create_domain(db, domain)
|
return create_domain(db, domain)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
raise APIException('platform:domain',request.url._url,f"Error occurred while create domain: {str(e)}")
|
raise APIException('platform:domain',request.url._url,f"Error occurred while create domain:",e)
|
||||||
|
|
||||||
|
|
||||||
@r.put(
|
@r.put(
|
||||||
@@ -215,7 +215,7 @@ async def domain_edit(
|
|||||||
try:
|
try:
|
||||||
return edit_domain(db, domain)
|
return edit_domain(db, domain)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
raise APIException('platform:domain',request.url._url,f"Error occurred while edit domain: {str(e)}")
|
raise APIException('platform:domain',request.url._url,f"Error occurred while edit domain:",e)
|
||||||
|
|
||||||
|
|
||||||
@r.delete(
|
@r.delete(
|
||||||
@@ -229,7 +229,7 @@ async def domain_delete(
|
|||||||
try:
|
try:
|
||||||
return delete_domain(db,id)
|
return delete_domain(db,id)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
raise APIException('platform:domain',request.url._url,f"Error occurred while delete domain: {str(e)}")
|
raise APIException('platform:domain',request.url._url,f"Error occurred while delete domain:",e)
|
||||||
|
|
||||||
@r.get(
|
@r.get(
|
||||||
"/domain",
|
"/domain",
|
||||||
@@ -245,7 +245,7 @@ async def userdomain_details(
|
|||||||
domains = get_domain(db, user.id)
|
domains = get_domain(db, user.id)
|
||||||
return domains
|
return domains
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
raise APIException('platform:domain',request.url._url,f"Error occurred while get user({user.id}) domain: {str(e)}")
|
raise APIException('platform:domain',request.url._url,f"Error occurred while get user({user.id}) domain:",e)
|
||||||
|
|
||||||
@r.post(
|
@r.post(
|
||||||
"/domain/{userid}",
|
"/domain/{userid}",
|
||||||
@@ -261,7 +261,7 @@ async def create_userdomain(
|
|||||||
domain = add_userdomain(db, userid,domainids)
|
domain = add_userdomain(db, userid,domainids)
|
||||||
return domain
|
return domain
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
raise APIException('platform:domain',request.url._url,f"Error occurred while add user({userid}) domain: {str(e)}")
|
raise APIException('platform:domain',request.url._url,f"Error occurred while add user({userid}) domain:",e)
|
||||||
|
|
||||||
@r.delete(
|
@r.delete(
|
||||||
"/domain/{domainid}/{userid}", response_model_exclude_none=True
|
"/domain/{domainid}/{userid}", response_model_exclude_none=True
|
||||||
@@ -275,7 +275,7 @@ async def userdomain_delete(
|
|||||||
try:
|
try:
|
||||||
return delete_userdomain(db, userid,domainid)
|
return delete_userdomain(db, userid,domainid)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
raise APIException('platform:delete',request.url._url,f"Error occurred while delete user({userid}) domain: {str(e)}")
|
raise APIException('platform:delete',request.url._url,f"Error occurred while delete user({userid}) domain:",e)
|
||||||
|
|
||||||
|
|
||||||
@r.get(
|
@r.get(
|
||||||
@@ -292,7 +292,7 @@ async def get_useractivedomain(
|
|||||||
domain = get_activedomain(db, user.id)
|
domain = get_activedomain(db, user.id)
|
||||||
return domain
|
return domain
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
raise APIException('platform:activedomain',request.url._url,f"Error occurred while get user({user.id}) activedomain: {str(e)}")
|
raise APIException('platform:activedomain',request.url._url,f"Error occurred while get user({user.id}) activedomain:",e)
|
||||||
|
|
||||||
@r.put(
|
@r.put(
|
||||||
"/activedomain/{domainid}",
|
"/activedomain/{domainid}",
|
||||||
@@ -308,7 +308,7 @@ async def update_activeuserdomain(
|
|||||||
domain = active_userdomain(db, user.id,domainid)
|
domain = active_userdomain(db, user.id,domainid)
|
||||||
return domain
|
return domain
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
raise APIException('platform:activedomain',request.url._url,f"Error occurred while update user({user.id}) activedomain: {str(e)}")
|
raise APIException('platform:activedomain',request.url._url,f"Error occurred while update user({user.id}) activedomain:",e)
|
||||||
|
|
||||||
@r.get(
|
@r.get(
|
||||||
"/events",
|
"/events",
|
||||||
@@ -324,7 +324,7 @@ async def event_data(
|
|||||||
events = get_events(db)
|
events = get_events(db)
|
||||||
return events
|
return events
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
raise APIException('platform:events',request.url._url,f"Error occurred while get events: {str(e)}")
|
raise APIException('platform:events',request.url._url,f"Error occurred while get events:",e)
|
||||||
|
|
||||||
|
|
||||||
@r.get(
|
@r.get(
|
||||||
@@ -342,4 +342,4 @@ async def eventactions_data(
|
|||||||
actions = get_eventactions(db,eventid)
|
actions = get_eventactions(db,eventid)
|
||||||
return actions
|
return actions
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
raise APIException('platform:eventactions',request.url._url,f"Error occurred while get eventactions: {str(e)}")
|
raise APIException('platform:eventactions',request.url._url,f"Error occurred while get eventactions:",e)
|
||||||
@@ -1,10 +1,19 @@
|
|||||||
|
from fastapi import HTTPException, status
|
||||||
from app.db.schemas import ErrorCreate
|
from app.db.schemas import ErrorCreate
|
||||||
from app.db.session import SessionLocal
|
from app.db.session import SessionLocal
|
||||||
from app.db.crud import create_log
|
from app.db.crud import create_log
|
||||||
|
|
||||||
class APIException(Exception):
|
class APIException(Exception):
|
||||||
|
|
||||||
def __init__(self,location:str,title:str,content:str):
|
def __init__(self,location:str,title:str,content:str,e:Exception):
|
||||||
|
if(str(e) == ''):
|
||||||
|
content += e.detail
|
||||||
|
self.detail = e.detail
|
||||||
|
self.status_code = e.status_code
|
||||||
|
else:
|
||||||
|
self.detail = str(e)
|
||||||
|
content += str(e)
|
||||||
|
self.status_code = 500
|
||||||
if(len(content) > 5000):
|
if(len(content) > 5000):
|
||||||
content =content[0:5000]
|
content =content[0:5000]
|
||||||
self.error = ErrorCreate(location=location,title=title,content=content)
|
self.error = ErrorCreate(location=location,title=title,content=content)
|
||||||
|
|||||||
@@ -54,8 +54,8 @@ async def api_exception_handler(request: Request, exc: APIException):
|
|||||||
loop = asyncio.get_event_loop()
|
loop = asyncio.get_event_loop()
|
||||||
loop.run_in_executor(None,writedblog,exc)
|
loop.run_in_executor(None,writedblog,exc)
|
||||||
return JSONResponse(
|
return JSONResponse(
|
||||||
status_code=400,
|
status_code=exc.status_code,
|
||||||
content={"detail": f"{exc.error.content}"},
|
content={"detail": f"{exc.detail}"},
|
||||||
)
|
)
|
||||||
|
|
||||||
@app.get("/api/v1")
|
@app.get("/api/v1")
|
||||||
|
|||||||
Reference in New Issue
Block a user