Skip to content

Commit

Permalink
Handle a CDKException thrown by the Parser by throwing an IllegalArgu…
Browse files Browse the repository at this point in the history
…mentException in the constructor

Signed-off-by: jonalv <jonathan.alvarsson@gmail.com>
  • Loading branch information
gilleain authored and egonw committed Sep 12, 2011
1 parent 6a98855 commit face5c5
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions src/main/org/openscience/cdk/smiles/smarts/SMARTSQueryTool.java
Expand Up @@ -20,6 +20,13 @@
*/
package org.openscience.cdk.smiles.smarts;

import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

import org.openscience.cdk.CDKConstants;
import org.openscience.cdk.annotations.TestClass;
import org.openscience.cdk.annotations.TestMethod;
Expand All @@ -44,13 +51,6 @@
import org.openscience.cdk.tools.LoggingToolFactory;
import org.openscience.cdk.tools.manipulator.AtomContainerManipulator;

import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

/**
* This class provides a easy to use wrapper around SMARTS matching functionality. <p/> User code that wants to do
* SMARTS matching should use this rather than using SMARTSParser (and UniversalIsomorphismTester) directly. Example
Expand Down Expand Up @@ -138,6 +138,8 @@ public SMARTSQueryTool(String smarts) {
initializeQuery();
} catch (TokenMgrError error) {
throw new IllegalArgumentException("Error parsing SMARTS", error);
} catch (CDKException error) {
throw new IllegalArgumentException("Error parsing SMARTS", error);
}
}

Expand Down Expand Up @@ -480,7 +482,7 @@ private void initializeRecursiveSmartsAtom(IAtom atom, IAtomContainer atomContai
}
}

private void initializeQuery() {
private void initializeQuery() throws CDKException {
matchingAtoms = null;
query = cache.get(smarts);
if (query == null) {
Expand Down

0 comments on commit face5c5

Please sign in to comment.