Commit 0772dbfd authored by John Red Medrano's avatar John Red Medrano

Merge pull request #413 in RMS/api-main-service from red-develop to RMSv2

* commit 'b9f23537':
  added integrityError to catch database level error
parents 7c949447 b9f23537
......@@ -16,6 +16,7 @@ from app.applicationlayer.cms.allowed_company.table_filter import (
)
from django.db import transaction
from rest_framework.exceptions import ValidationError
from django.db import IntegrityError
class AllowedCompanyViewSet(viewsets.ModelViewSet):
......@@ -83,13 +84,24 @@ class AllowedCompanyViewSet(viewsets.ModelViewSet):
}
return Response(message, status=status.HTTP_400_BAD_REQUEST)
except Exception as e:
print('ddd')
except IntegrityError as e:
print(str(e))
error = 'adding the same departments under same Company is not allowed'
message = {
'code': 500,
'code': 400,
'status': 'failed',
'message': error,
}
return Response(message,
status=status.HTTP_400_BAD_REQUEST)
except Exception as e:
# print(str(e))
# error = 'adding the same departments under same Company is not allowed'
message = {
'code': 500,
'status': 'failed',
'message': str(e),
}
return Response(message,
status=status.HTTP_500_INTERNAL_SERVER_ERROR)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment