Hi Bimali,
It is suggesting to throw the runtime exceptions other than just logging.
have you tried doing that?

Regards,
Vinod

On Wed, Aug 12, 2015 at 12:44 PM, Bimali Dayananda <[email protected]> wrote:

> Hi,
>
> My code is as below.
>
> try{
>      configurationElement = AXIOMUtil.stringToOM(xmlFile);
> }catch (XMLStreamException e) {
>     log.error("Unable to load files ");
> }
>
> When I analyze it through FindBugs I get the following bug report.
>
>      "Exception is caught when the exception is not caught.
>
>        This method uses a try-catch block that catches Exception objects,
> but Exception is not thrown within the try block, and RuntimeException is
> not explicitly caught. It is a common bug pattern to say try { ... } catch
> (Exception e) { something } as a shorthand for catching a number of types
> of exception each of whose catch blocks is identical, but this construct
> also accidentally catches RuntimeException as well, masking potential bugs.
>
> A better approach is to either explicitly catch the specific exceptions
> that are thrown, or to explicitly catch RuntimeException exception, rethrow
> it, and then catch all non-Runtime Exceptions, as shown below:
>
>   try {
>     ...
>   } catch (RuntimeException e) {
>     throw e;
>   } catch (Exception e) {
>     ... deal with all non-runtime exceptions ...
>   }"
>
> I tried the solution they have suggested. But it is not working.
>
> Any idea of this?
>
> Thanks.
>
>
>
>
>
>
>
> --
> Bimali Dayananda
> Intern-Software Engineering
> Mobile : +94(77) 571 6618
> [email protected]
>
> _______________________________________________
> Dev mailing list
> [email protected]
> http://wso2.org/cgi-bin/mailman/listinfo/dev
>
>


-- 
Vinod Kavinda
Software Engineer
*WSO2 Inc. - lean . enterprise . middleware <http://www.wso2.com>.*
Mobile : +94 (0) 712 415544
Blog : http://soatechflicks.blogspot.com/
_______________________________________________
Dev mailing list
[email protected]
http://wso2.org/cgi-bin/mailman/listinfo/dev

Reply via email to