Skip to content

Commit

Permalink
Better error handling in non-strict mode.
Browse files Browse the repository at this point in the history
  • Loading branch information
johnmay committed Aug 26, 2017
1 parent 11473ec commit d98a113
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
Expand Up @@ -1197,8 +1197,10 @@ void readPropertiesFast(final BufferedReader input, final IAtomContainer contain

// check of ill specified atomic mass
for (IAtom atom : container.atoms()) {
if (atom.getMassNumber() != null && atom.getMassNumber() < 0)
throw new CDKException("Unstable use of mass delta on " + atom.getSymbol() + " please use M ISO");
if (atom.getMassNumber() != null && atom.getMassNumber() < 0) {
handleError("Unstable use of mass delta on " + atom.getSymbol() + " please use M ISO");
atom.setMassNumber(null);
}
}


Expand Down
Expand Up @@ -1701,15 +1701,15 @@ public void testSgroupBracketStyle() throws Exception {
@Test(expected = CDKException.class)
public void seaborgiumMassDelta() throws Exception {
try (InputStream in = getClass().getResourceAsStream("seaborgium.mol");
MDLV2000Reader mdlr = new MDLV2000Reader(in)) {
MDLV2000Reader mdlr = new MDLV2000Reader(in, Mode.STRICT)) {
IAtomContainer mol = mdlr.read(new AtomContainer());
}
}

@Test
public void seaborgiumAbsMass() throws Exception {
try (InputStream in = getClass().getResourceAsStream("seaborgium_abs.mol");
MDLV2000Reader mdlr = new MDLV2000Reader(in)) {
MDLV2000Reader mdlr = new MDLV2000Reader(in, Mode.STRICT)) {
IAtomContainer mol = mdlr.read(new AtomContainer());
assertThat(mol.getAtom(0).getMassNumber(), is(261));
}
Expand Down

0 comments on commit d98a113

Please sign in to comment.