Handle DuplicateKeyError on org rename requests (#514)
* Handle DuplicateKeyError on org rename requests
This commit is contained in:
parent
9f0abd6a28
commit
231c37108c
@ -407,7 +407,11 @@ def init_orgs_api(app, mdb, user_manager, invites, user_dep: User):
|
||||
org: Organization = Depends(org_owner_dep),
|
||||
):
|
||||
org.name = rename.name
|
||||
await ops.update(org)
|
||||
try:
|
||||
await ops.update(org)
|
||||
except DuplicateKeyError:
|
||||
# pylint: disable=raise-missing-from
|
||||
raise HTTPException(status_code=400, detail="duplicate_org_name")
|
||||
|
||||
return {"updated": True}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user