Skip to content
Snippets Groups Projects
Commit 50a5b827 authored by Piotr Gawron's avatar Piotr Gawron
Browse files

error handling improved when source xml for drugs is invalid

parent f2ea69f2
No related branches found
No related tags found
No related merge requests found
......@@ -496,10 +496,18 @@ public class ChEMBLParser extends DrugAnnotation implements IExternalService {
Document document = getXmlDocumentFromString(content);
Node response = getNode("response", document);
if (response == null) {
throw new DrugSearchException("Invalid source XML for drug: " + drugId);
}
Node moleculesNode = getNode("molecules", response);
if (moleculesNode == null) {
throw new DrugSearchException("Invalid source XML for drug: " + drugId);
}
Node moleculeNode = getNode("molecule", moleculesNode);
if (moleculeNode == null) {
throw new DrugSearchException("Invalid source XML for drug: " + drugId);
}
return parseDrug(moleculeNode);
} catch (IOException e) {
throw new DrugSearchException("Problem with accessing external database for id: " + drugId, e);
} catch (InvalidXmlSchemaException e) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment