I have a RESTful web application with an endpoint that allows the user to delete a particular resource by providing its id:
DELETE /rules/{id}
In some cases, one rule
may reference another rule
. If Rule A
references Rule B
, and a user attempts to delete Rule B
, I'm not allowing that.
In my server code, I'd like the delete method in my manager (one layer deeper than the REST method) to throw an exception when a rule cannot be deleted because it's being referenced by another rule. My REST method will then have a catch block for this exception and formulate the appropriate HTTP response.
What is an appropriate exception for my manager method to throw in this case?