Hello folks! I'm trying to do a bit of refactoring in my smartgwt spring services.
A common use case looks like this:
The error code i set in the response is then taken care of in my custom error handling in the client, to present localized user messages and perform context-aware error handling etc.
Now, i would like to centralize this to make the code look cleaner, so i looked a bit at IDACall. From what i can see, in your 'handleDSRequest' method you catch Throwables and then call handleDSRequestError and return what that method returns.
Would it be a "best practice" solution for me to extend IDACall, override the handleDSRequestError and move the code i showed above here (and call super.handleDSRequest if i could not handle the exception)?
Would be great to hear your thoughts.
A common use case looks like this:
Code:
DSResponse resp = new DSResponse(); try { resp.setData(customService.doAddOfTheThing()); } catch (CustomTypeOfException ex) { resp.setStatus(Utils.mapExceptionToGlobalResponseCode(ex.getErrorType())); } catch (Exception e) { resp.setStatus(GlobalWebErrorCodeEnum.SYSTEM_ERROR); } return resp;
Now, i would like to centralize this to make the code look cleaner, so i looked a bit at IDACall. From what i can see, in your 'handleDSRequest' method you catch Throwables and then call handleDSRequestError and return what that method returns.
Would it be a "best practice" solution for me to extend IDACall, override the handleDSRequestError and move the code i showed above here (and call super.handleDSRequest if i could not handle the exception)?
Would be great to hear your thoughts.
Comment