I have a class like that:
@Override
public StudentDTO getStudent(@WebParam(name = "name") String studentName) {
StudentDTO student = new StudentDTO();
try {
student = studentService.findStudentByName(studentName);
} catch (Exception e) {
return new ErrorActionResponse("student couldn't find by name");
}
return student;
}
As usual this doesn't work because of return type is StudentDTO and I try to return another type of class: ErrorActionResponse. ErrorActionResponse is an error class that has detailed information about error.
How can I design my web service architecture that can handle error situations? (At my REST architecture I write error information into response and send error to client side)