0

When I try to delete an entity in my database I get a ForeignKey Constraint Exception.

I expect that exception, handle it on the server but also want to handle it on the client.

What status code should I use to say: You can not delete this entity and prevent on the client side the deletion of the entity in the UI.

Pascal
  • 12,265
  • 25
  • 103
  • 195

1 Answers1

1

There is only one real "exception" code - 500.

For some operations code from 4xx range may be suitable. Maybe "403-forbidden" wold be ok for this case.

If you need to have more comprehensive client side handling - send 200 with response including error information with empty value instead of result.

Sam Axe
  • 33,313
  • 9
  • 55
  • 89
Alexei Levenkov
  • 98,904
  • 14
  • 127
  • 179