I have the following code and findbugs complains that "Exception is caught when Exception is not thrown
" under dodgy code. I do not understand how to solve this. getPMMLExportable
throws a MLPMMLExportException
.
public String exportAsPMML(MLModel model) throws MLPmmlExportException {
Externalizable extModel = model.getModel();
PMMLExportable pmmlExportableModel = null;
try {
pmmlExportableModel = ((PMMLModelContainer) extModel).getPMMLExportable();
} catch (MLPmmlExportException e) {
throw new MLPmmlExportException(e);
}
}
This is a very famous findbug warning,
according to official documentation this kind of warning is generated when
catch(Exception e)
to catch all types of exceptions at once, it could mask actual programming problems, so findbugs asks you to catch specific exception, so that run-time exceptions can be thrown which indicate programming problems.for more understanding(and the solution as well) you can have look at the official documentation.
for your case it seems that statements in try
clause do not throw the exception you are handling in catch
clause
hope this helps!
Good luck!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With