Error handling for delete api endpoints