diff --git a/backend/app/api/api_v1/routers/kintone.py b/backend/app/api/api_v1/routers/kintone.py index e4ba734..d10885d 100644 --- a/backend/app/api/api_v1/routers/kintone.py +++ b/backend/app/api/api_v1/routers/kintone.py @@ -194,8 +194,9 @@ def addfieldstokintone(app:str,fields:dict,c:config.KINTONE_ENV,revision:str = N else: data = {"app":app,"properties":fields} r = httpx.post(url,headers=headers,data=json.dumps(data)) + r.raise_for_status() return r.json() - + def updatefieldstokintone(app:str,revision:str,fields:dict,c:config.KINTONE_ENV): headers={config.API_V1_AUTH_KEY:c.API_V1_AUTH_VALUE,"Content-Type": "application/json"} url = f"{c.BASE_URL}{config.API_V1_STR}/preview/app/form/fields.json" diff --git a/backend/app/core/apiexception.py b/backend/app/core/apiexception.py index b6908d8..808caef 100644 --- a/backend/app/core/apiexception.py +++ b/backend/app/core/apiexception.py @@ -1,22 +1,35 @@ from fastapi import HTTPException, status +import httpx from app.db.schemas import ErrorCreate from app.db.session import SessionLocal from app.db.crud import create_log class APIException(Exception): - - 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): - content =content[0:5000] - self.error = ErrorCreate(location=location,title=title,content=content) + def __init__(self, location: str, title: str, content: str, e: Exception): + self.detail = str(e) + self.status_code = 500 + if isinstance(e,httpx.HTTPStatusError): + try: + error_response = e.response.json() + self.detail = error_response.get('message', self.detail) + self.status_code = e.response.status_code + content += self.detail + except ValueError: + pass + elif hasattr(e, 'detail'): + self.detail = e.detail + self.status_code = e.status_code if hasattr(e, 'status_code') else 500 + content += e.detail + else: + self.detail = str(e) + self.status_code = 500 + content += str(e) + + if len(content) > 5000: + content = content[:5000] + + self.error = ErrorCreate(location=location, title=title, content=content) + super().__init__(self.error) def writedblog(exc: APIException): db = SessionLocal() diff --git a/frontend/src/components/DocUpload.vue b/frontend/src/components/DocUpload.vue index 5dd0c46..3a89476 100644 --- a/frontend/src/components/DocUpload.vue +++ b/frontend/src/components/DocUpload.vue @@ -15,7 +15,7 @@