Skip to content

Commit

Permalink
fix: improve logging if organization patch fails
Browse files Browse the repository at this point in the history
  • Loading branch information
spwoodcock committed Nov 27, 2023
1 parent 95fdbc4 commit 3813d78
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/backend/app/organization/organization_routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
# You should have received a copy of the GNU General Public License
# along with FMTM. If not, see <https:#www.gnu.org/licenses/>.
#

"""Routes for organization management."""

from fastapi import (
APIRouter,
Expand All @@ -25,6 +25,7 @@
HTTPException,
UploadFile,
)
from loguru import logger as log
from sqlalchemy.orm import Session

from ..db import database
Expand Down Expand Up @@ -77,7 +78,8 @@ async def create_organization(
db (Session): The database session. Dependency.
Returns:
dict: A dictionary with a message indicating successful creation of the organization.
dict: A dictionary with a message indicating successful creation
of the organization.
"""
# Check if the organization with the same already exists
if await organization_crud.get_organisation_by_name(db, name=name):
Expand Down Expand Up @@ -106,13 +108,17 @@ async def update_organization(
)
return organization
except Exception as e:
raise HTTPException(status_code=400, detail=f"Error updating organization: {e}")
log.exception(e)
raise HTTPException(
status_code=400, detail="Error updating organization."
) from e


@router.delete("/{organization_id}")
async def delete_organisations(
organization_id: int, db: Session = Depends(database.get_db)
):
"""Delete an organization."""
organization = await organization_crud.get_organisation_by_id(db, organization_id)

if not organization:
Expand Down

0 comments on commit 3813d78

Please sign in to comment.