How to response error to the front ?

Imaging you want to delete a record in a datatable ,you make a delete request to the server with the help of REST mode,but for some reason the record can’t be deleted,then how to make the response from the server and what is ‘error’ for the front end.

For those who also interested, the corresponding docs. Further error handling is mentioned here.