Create Org API endpoint must return better error for duplicate names
cnk opened this issue · comments
We need to put a try/except around saving the org and then return sensible error messages in JSON format.
Example of an error we need to catch and report:
IntegrityError at /api/organizations/
duplicate key value violates unique constraint "data_organization_name_key"
DETAIL: Key (name)=(test org 2) already exists.
Request Method: POST
Request URL: http://localhost:8888/api/organizations/
Django Version: 3.1.8
Exception Type: IntegrityError
Exception Value:
duplicate key value violates unique constraint "data_organization_name_key"
DETAIL: Key (name)=(test org 2) already exists.