#138 All catch() clauses must report to logger

closed
None
4
2012-10-08
2003-10-21
No

All catch clauses must report a message to logger.errror().
The stack trace must be reported by using
logger.debug(exception). The latter will automatically
list the full stack trace in the log.

Current occurrences of catch() are listed below.
I will attack them step by step.
Some of them write to System.out and are command line
apps, so I suggest to keep that behaviour.

catch(
D:\develop\cdk\src\org\openscience\cdk\applications\IUPACNameGenerator.java
77: } catch(Exception exc) {
D:\develop\cdk\src\org\openscience\cdk\database\DBAdmin.java
123: } catch(Exception exc) {
214: }catch(Exception exc) {
228: }catch(Exception exc) {
253: catch(Exception exc)
312: } catch(Exception exc) {
359: catch(Exception exc)
383: catch(Exception exc)
408: catch(Exception exc)
420: catch(Exception exc)
437: catch(Exception exc)
450: catch(Exception exc)
D:\develop\cdk\src\org\openscience\cdk\database\DBWriter.java
127: } catch(Exception exc) {
D:\develop\cdk\src\org\openscience\cdk\graph\invariant\IChIGenerator.java
116: } catch(Exception exception) {
D:\develop\cdk\src\org\openscience\cdk\io\MDLWriter.java
115: catch(Exception ex){
D:\develop\cdk\src\org\openscience\cdk\io\program\GaussianInputWriter.java
79: } catch(Exception ex) {
D:\develop\cdk\src\org\openscience\cdk\io\SMILESWriter.java
132: } catch(Exception exc) {
D:\develop\cdk\src\org\openscience\cdk\io\XYZWriter.java
65: } catch(Exception ex) {
D:\develop\cdk\src\org\openscience\cdk\isomorphism\mcss\RTools.java
604: catch(CDKException ex)
611: catch(IOException e)
D:\develop\cdk\src\org\openscience\cdk\layout\RingPlacer.java
136: catch(Exception exc)
279: catch(Exception exc)
469: catch(Exception exc)
D:\develop\cdk\src\org\openscience\cdk\layout\StructureDiagramGenerator.java
392: } catch(Exception exc) {
608: } catch(Exception exc) {}
D:\develop\cdk\src\org\openscience\cdk\renderer\MoleculeViewer2D.java
198: catch(Exception exc)
D:\develop\cdk\src\org\openscience\cdk\Ring.java
152: catch(Exception exc)
D:\develop\cdk\src\org\openscience\cdk\ringsearch\AllRingsFinder.java
241: catch(Exception exc)
D:\develop\cdk\src\org\openscience\cdk\ringsearch\Path.java
138: catch(Exception exc)
D:\develop\cdk\src\org\openscience\cdk\structgen\stochastic\operator\CrossoverMachine.java
74: catch(java.lang.Exception ex){ }
D:\develop\cdk\src\org\openscience\cdk\structgen\VicinitySampler.java
264: catch(Exception exc)
D:\develop\cdk\src\org\openscience\cdk\templates\MoleculeFactory.java
711: catch(Exception exc)
727: catch(Exception exc)
D:\develop\cdk\src\org\openscience\cdk\test\controller\ControllerTest.java
65: // catch(Exception exc)
273: catch(Exception exc)
D:\develop\cdk\src\org\openscience\cdk\test\database\DatabaseReaderTest.java
54: catch(Exception exc)
D:\develop\cdk\src\org\openscience\cdk\test\fingerprint\FingerprinterTest.java
226: catch(Exception exc)
D:\develop\cdk\src\org\openscience\cdk\test\graph\invariant\EquivalentClassPartitionerTest.java
167: catch(Exception exc)
252: catch(Exception exc)
D:\develop\cdk\src\org\openscience\cdk\test\graph\invariant\MorganNumberToolsTest.java
63: catch(Exception exc)
D:\develop\cdk\src\org\openscience\cdk\test\internet\DADMLTest.java
56: } catch(Exception exc) {
D:\develop\cdk\src\org\openscience\cdk\test\io\FileReaderTest.java
81: } catch(Exception exc) {
D:\develop\cdk\src\org\openscience\cdk\test\io\ZMatrixReaderTest.java
68: } catch(Exception exc)
D:\develop\cdk\src\org\openscience\cdk\test\isomorphism\IsomorphismTesterTest.java
133: catch(Exception exc)
D:\develop\cdk\src\org\openscience\cdk\test\isomorphism\UniversalIsomorphismTesterTest.java
112: catch(Exception exc)
D:\develop\cdk\src\org\openscience\cdk\test\layout\HydrogenPlacerTest.java
143: catch(Exception exc)
D:\develop\cdk\src\org\openscience\cdk\test\layout\StructureDiagramGeneratorTest.java
191: catch(Exception exc)
D:\develop\cdk\src\org\openscience\cdk\test\math\qm\GaussiansCalculationTest.java
90: } catch(Exception exc)
D:\develop\cdk\src\org\openscience\cdk\test\math\qm\VisualGaussiansCalculationTest.java
133: } catch(Exception exc)
D:\develop\cdk\src\org\openscience\cdk\test\renderer\AcceleratedRenderer3DTest.java
80: } catch(Exception exc)
D:\develop\cdk\src\org\openscience\cdk\test\renderer\DrawPolygonTest.java
84: catch(Exception exc)
D:\develop\cdk\src\org\openscience\cdk\test\renderer\Renderer2DTest.java
83: catch(Exception exc)
D:\develop\cdk\src\org\openscience\cdk\test\renderer\TableTest.java
65: } catch(Exception exc) {
D:\develop\cdk\src\org\openscience\cdk\test\ringsearch\AllRingsFinderTest.java
71: catch(Exception exc)
107: catch(Exception exc)
159: catch(Exception exc)
D:\develop\cdk\src\org\openscience\cdk\test\smiles\SmilesGeneratorTest.java
76: catch(Exception exc) {
95: catch(Exception exc) {
126: catch(IOException ex){}
127: catch(ClassNotFoundException ex){}
135: catch(Exception exc) {
148: catch(Exception exc) {
186: catch(IOException ex){}
187: catch(ClassNotFoundException ex){}
194: catch(Exception exc) {
206: catch(Exception exc) {
249: catch(IOException ex){}
250: catch(ClassNotFoundException ex){}
257: catch(Exception exc) {
269: catch(Exception exc) {
297: catch(IOException ex){}
298: catch(ClassNotFoundException ex){}
307: catch(Exception exc) {
320: catch(Exception exc) {
331: catch(IOException ex){}
332: catch(ClassNotFoundException ex){}
339: catch(Exception exc) {
350: catch(Exception exc) {
370: } catch(Exception exc) {
395: } catch(Exception exc) {
438: catch(Exception exc)
D:\develop\cdk\src\org\openscience\cdk\test\structgen\deterministic\EquivalentClassesDeterministicGeneratorTest.java
104: catch(Exception exc)
D:\develop\cdk\src\org\openscience\cdk\test\structgen\RandomStructureGeneratorTest.java
131: catch(Exception exc)
D:\develop\cdk\src\org\openscience\cdk\test\structgen\SingleStructureRandomGeneratorTest.java
76: catch(Exception exc)
117: catch(Exception exc)
148: catch(CDKException
ex){System.err.println(ex.getMessage());}
D:\develop\cdk\src\org\openscience\cdk\test\structgen\VicinitySamplerTest.java
89: catch(Exception exc)
136: catch(Exception exc)
D:\develop\cdk\src\org\openscience\cdk\test\tools\AtomTypeFactoryTest.java
48: } catch(Exception exc) {
90: } catch(Exception exc) {
D:\develop\cdk\src\org\openscience\cdk\test\tools\BremserPredictorTest.java
162: }catch(org.openscience.cdk.exception.CDKException exc)
257: catch(Exception exc)
276: catch(Exception exc)
296: catch(Exception exc)
D:\develop\cdk\src\org\openscience\cdk\test\tools\HydrogenAdderTest.java
455: } catch(Exception exception) {
D:\develop\cdk\src\org\openscience\cdk\test\tools\IsotopeFactoryTest.java
62: catch(Exception exc)
75: catch(Exception exc)
86: catch(Exception exc)
136: catch(Exception exc)
D:\develop\cdk\src\org\openscience\cdk\tools\CDKBasedAtomTypeConfigurator.java
59: } catch(Exception exc) {
66: } catch(Exception exc) {
D:\develop\cdk\src\org\openscience\cdk\tools\HOSECodeGenerator.java
744: catch(Exception exc)
766: catch(Exception exc)

Discussion

  • Christoph Steinbeck

    Logged In: YES
    user_id=54358

    In fact there were many more occurences because I searched
    for "catch(" instead of just "catch" and there are many
    instances of "catch (".

    Done so far:

    applications.FileConvertor.java
    applications.FileFormatGuesser.java
    applications.FingerPrinter.java
    applications.IUPACNameGenerator.java
    applications.plugin.CDKPluginManager.java
    applications.SubstructureFinder.java
    applications.Validator.java
    applications.Viewer.java
    Atom.java
    AtomContainer.java
    Bond.java
    ChemObject.java
    controller.Controller2D.java
    Crystal.java
    database.DBAdmin.java
    database.DBReader.java
    database.DBWriter.java
    database.XindiceReader.java
    dict.Dictionary.java
    dict.DictionaryDatabase.java
    Element.java

     
  • Egon Willighagen

    Logged In: YES
    user_id=25678

    I've added a reasonable PMD test. See the PMD output from
    pmd.xml to find the violations of this rule.

     
  • Egon Willighagen

    Logged In: YES
    user_id=25678

    I'm going to close this bug, since it's of too low priority at this moment.
    Individual instances of this bug can be filed, and patches are welcome.
    The PMD results are for each CDK module on the CDK website.

     

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks