Advertisement
patstuart

Error logic in DAO

Aug 13th, 2014
339
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 5 0.85 KB | None | 0 0
  1. //DTO
  2. public class UpdateResponse {
  3.     int returnCode;
  4.     String returnMessage;
  5.     Calendar updateTimestamp;
  6.     String updateUser;
  7.  
  8.     //<getters and setters>
  9. }
  10.  
  11. //DAO
  12. public UpdateResponse update() throws ServiceException {
  13.     try {
  14.     return translateXmlIntoUpdateResponse(doQuery());
  15.     } catch (RemoteException e) {
  16.         throw new ServiceException(e);
  17.     }
  18. }
  19.  
  20. //Business
  21. public void stuff() throws MyException {
  22.     // [preceding code ...]
  23.     UpdateResponse updateResponse = dao.update();
  24.     try{
  25.         updateResponse = dao.update();
  26.     } catch (ServiceException e) {
  27.         throw new MyException(e);
  28.     }
  29.     if (updateResponse.getReturnCode() != 0) {
  30.         throw MyException("Code = " + updateResponse.getReturnCode() +
  31.             "; message = " + updateResponse.getMessage());
  32.     }
  33.     // [proceeding code ...]
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement