MolImport's Error

User 7c5047cd7b

26-05-2006 05:50:21

Hi


I get the following error, while using MolImporter .





--------------------------------------------------


java.io.IOException: Bad bond type 0


at chemaxon.marvin.modules.MolImport.readBondBlockV2(MolImport.java:878)


at chemaxon.marvin.modules.MolImport.readCtab(MolImport.java:706)


at chemaxon.marvin.modules.MolImport.readMol0(MolImport.java:454)


at chemaxon.marvin.modules.MolImport.readMol(MolImport.java:234)


at chemaxon.formats.MolImporter.readMol(MolImporter.java:613)


at chemaxon.formats.MolImporter.read(MolImporter.java:517)


at chemaxon.formats.MolImporter.read(MolImporter.java:486)


at chemaxon.util.MolHandler.importMol(MolHandler.java:681)


at chemaxon.util.MolHandler.setMolecule(MolHandler.java:159)


at chemaxon.util.MolHandler.<init>(MolHandler.java:94)


---------------------------------------------


My question is :


I failed to catch the error in MolFormatException,IOException,Exception.


I would like to know how to catch the error in a Java application.


(Maybe you need throw more errors from MolImporter)

ChemAxon 9c0afc9aaf

26-05-2006 14:30:38

Hi,





Could you tell me which version of JChem you use ?





Also, could you attach the structure, so we can examine if it is an import error or a faulty structure source ?


(You can send it by e-mail if the structure is proprietary)





Best regards,





Szilard

ChemAxon 9c0afc9aaf

26-05-2006 15:30:25

Meanwhile I have found the most likely cause for the error and the confusion, and artificially reproduced the problem.


(luckily the affected code didn't change recently, but usually the JChem version is crucial for us in bug reports)





The mol file does not seem to be valid, it contains an illegal bond type.


(bond type should be between 1 and 8)


Please see the MDL reference for details:


http://www.mdl.com/downloads/public/ctfile/ctfile.pdf








Otherwise you should be able to catch the exception as a MolFormatException (please see the attached test code).


What may be confusing for you is that


- the IOException is caught


- the stack trace is printed


- a MolFormatException is thrown with the same message.





I agree that this is not the nicest solution (the stack trace appears on the standard output no matter what), but you can certainly catch the exception.





As we will require Java 1.4 in future JChem versions, we will use embedded exceptions in the future, which are much nicer.





Best regards,





Szilard