proper raise

This commit is contained in:
Robert 2024-03-17 19:43:21 +07:00
parent f470a371e3
commit 0ba3b7b9ba
No known key found for this signature in database
GPG Key ID: F631C7FD957D5F22
4 changed files with 13 additions and 13 deletions

View File

@ -29,11 +29,11 @@ async def chain_upsert_controller(
except AssertionError: except AssertionError:
logger.exception(f"Unknown namespace_id {chain.namespace_id}") logger.exception(f"Unknown namespace_id {chain.namespace_id}")
return HTTPException(status_code=400, detail="Wrong namespace_id") raise HTTPException(status_code=400, detail="Wrong namespace_id")
except Exception: except Exception:
logger.exception(f"Error during chain upsert {chain.model_dump_json()}") logger.exception(f"Error during chain upsert {chain.model_dump_json()}")
return HTTPException(status_code=500, detail="Error during chain upsert") raise HTTPException(status_code=500, detail="Error during chain upsert")
@router.get("/list") @router.get("/list")
@ -50,11 +50,11 @@ async def chain_list_controller(
except AssertionError: except AssertionError:
logger.exception(f"Unknown namespace_id {namespace_id}") logger.exception(f"Unknown namespace_id {namespace_id}")
return HTTPException(status_code=400, detail="Wrong namespace_id") raise HTTPException(status_code=400, detail="Wrong namespace_id")
except Exception: except Exception:
logger.exception("Error during chain list") logger.exception("Error during chain list")
return HTTPException(status_code=500, detail="Error during chain list") raise HTTPException(status_code=500, detail="Error during chain list")
@router.get("/{chain_id}") @router.get("/{chain_id}")
@ -67,11 +67,11 @@ async def chain_get_controller(
except AssertionError: except AssertionError:
logger.warning(f"Chain not found {chain_id}") logger.warning(f"Chain not found {chain_id}")
return HTTPException(status_code=404, detail="Chain not found") raise HTTPException(status_code=404, detail="Chain not found")
except Exception: except Exception:
logger.exception("Error during chain get") logger.exception("Error during chain get")
return HTTPException(status_code=500, detail="Error during chain get") raise HTTPException(status_code=500, detail="Error during chain get")
@router.delete("/delete/{chain_id}") @router.delete("/delete/{chain_id}")
@ -84,4 +84,4 @@ async def chain_delete_controller(
except Exception: except Exception:
logger.exception("Error during chain deletion") logger.exception("Error during chain deletion")
return HTTPException(status_code=500, detail="Error during chain deletion") raise HTTPException(status_code=500, detail="Error during chain deletion")

View File

@ -20,7 +20,7 @@ async def namespace_controller(
except Exception: except Exception:
logger.exception(f"Error during namespace upsert {namespace.model_dump_json()}") logger.exception(f"Error during namespace upsert {namespace.model_dump_json()}")
return HTTPException(status_code=500, detail="Error during namespace upsert") raise HTTPException(status_code=500, detail="Error during namespace upsert")
# @router.get("/{namespace_name}") # @router.get("/{namespace_name}")
@ -33,8 +33,8 @@ async def namespace_get_by_name_controller(
except AssertionError: except AssertionError:
logger.warning(f"Namespace not found {namespace_name}") logger.warning(f"Namespace not found {namespace_name}")
return HTTPException(status_code=404, detail="Namespace not found") raise HTTPException(status_code=404, detail="Namespace not found")
except Exception: except Exception:
logger.exception("Error during chain get") logger.exception("Error during chain get")
return HTTPException(status_code=500, detail="Error during namespace get") raise HTTPException(status_code=500, detail="Error during namespace get")

View File

@ -42,8 +42,8 @@ async def run_chain_controller(
except AssertionError: except AssertionError:
logger.warning(f"Chain not found {run_chain_input.chain_id}") logger.warning(f"Chain not found {run_chain_input.chain_id}")
return HTTPException(status_code=404, detail="Chain not found") raise HTTPException(status_code=404, detail="Chain not found")
except Exception: except Exception:
logger.exception("Error during run chain") logger.exception("Error during run chain")
return HTTPException(status_code=500, detail="Error during run chain") raise HTTPException(status_code=500, detail="Error during run chain")

View File

@ -25,4 +25,4 @@ async def s3_controller(file: UploadFile):
except Exception: except Exception:
logger.exception("Error during s3 upload") logger.exception("Error during s3 upload")
return HTTPException(status_code=500, detail="Cannot upload") raise HTTPException(status_code=500, detail="Cannot upload")