I have an action retrieve data from web form and transform user's email and password to Service layer, if the email and password are validated, OK, this user is passed. But if reverse, how can I tell my action something wrong occurred ?
Now, my solution is throw an Exception in Service layer with a message "No, you can not login". But I am confused with Java Exception, maybe runtime exception should use as my way, but I am not sure.
If I design my service as : boolean isValidate(String email, String password), I always think it's not a good idea to return the logic to action and write if/else in my struts2 action.
So, what is the good way?
ps: including the scenario as follow
I want to add a keyword to database, but a unit key existed, so, what is the best way to tell my action: "ok, the keyword you give me has already existed!".
throw DuplicateResourceException or return other things?