Commit 50a5b827 authored by Piotr Gawron's avatar Piotr Gawron
Browse files

error handling improved when source xml for drugs is invalid

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