Reputation: 51
I'm doing some service related operation. is the below snippet valid?
try {
//some code here
} catch (ServiceException e) {
throw new ServiceException("Error!!!");
}
I'm catching ServiceException and throwing the same exception. Is it good practice ???
Upvotes: 1
Views: 3791
Reputation: 1207
You are not sure whether what you've written is good or bad. In this situation I would document myself a bit about the tools I plan to use, in this case the Exception mechanism from Java and then I would start asking questions:
Upvotes: 0
Reputation: 1
not good practice. because it is hard to find origin reason for the problem
Upvotes: 0
Reputation: 145
In catch part you actually catch main exception that occurred during code..and then you throw custom/ user readable exception from that..This is good practice.
Upvotes: 2