Reputation: 7869
I have a servlet that call this method
TemplateLoader.load(TemplateReplacer replacer);
The particular implementation of TemplateReplacer can generate a MalformedURLException, because it replaces URLs.
My dilemma is:
So, I'm stuck in this dilemma. What do you suggest me to do?
Upvotes: 0
Views: 60
Reputation: 6497
The solution to your problem is to define and use a custom exception. Your analysis in your #6 is flawed. The value that the custom exception provides is to group together (encapsulate) the various exceptions that might occur in the concrete implementations.
You may want to create more than one custom exception. For example, one to indicate a transient problem (and a retry might work) and one to indicate a fundamental problem with the configuration and that something needs to change before success is possible. If you create multiple exceptions, you probably should consider an inheritance hierarchy, so a caller can deal with the generic exception or with the specific flavors of the exception as appropriate.
Upvotes: 1