mardi 17 mars 2015

Is it good practice to throw exception from DAO layer to controller?

I am writing one REST api. There might be two exceptions in my DAO layer namely Exception_X and Exception_Y. If I encountered a exception Exception_X in DAO layer, my controller should return status code 200, if Exception_Y then 401 and if all goes well controller should return 201. Now what was I thinking that I will throw encountered exception as it is from DAO layer to controller via service layer and in catch block of controller I will return response. Is it acceptable or there is some other standard way?


Aucun commentaire:

Enregistrer un commentaire