java - How to do common Exception handling -


lets have hundred classes method signature, entry exit method class :

public map<string,object> dosome(map arg1, map arg2) 

and within method body there try/catch block. catch block catches exception , rethrows custom exception. earlier program abandon in catch block. need able return map has key value ("exception", "some went bad in class"). 1 way make additional method within dosome method (and push current code new one) , surround method call try/catch , in catch block catch custom exception , write generic method populate returning map
best way achieve of 100+ classes ?
wondering if such thing can achieved using spring aop ? of spring advices come across dont allow returning of values (meaning control never bubbles exception thrown from).
great if can point me specific examples.

this sounds can solved functionality provided parent class.

have each of 100 classes (really, 100??!) extend abstract parent class. have parent class define dosomething method:

public map<string,object> dosome(map arg1, map arg2) {    try {     dosomething(arg1, arg2);   } catch (exception e) {     // clever handling here   } } 

make sure dosomething() method defined abstract method in exceptionhandler. of course, better method names welcome.

each of subclasses implement own variation of dosomething().


Comments

Popular posts from this blog

java - Jmockit String final length method mocking Issue -

asp.net - Razor Page Hosted on IIS 6 Fails Every Morning -

c++ - wxwidget compiling on windows command prompt -