From: gmungoc Date: Mon, 3 Oct 2016 16:11:50 +0000 (+0100) Subject: JAL-2110 JAL-1705 handle not found (400) better X-Git-Tag: Release_2_10_0~20^2~4 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=7c692f60c72e7a76f5bb4b2129edf6b4330e0a02;p=jalview.git JAL-2110 JAL-1705 handle not found (400) better --- diff --git a/src/jalview/ext/ensembl/EnsemblRestClient.java b/src/jalview/ext/ensembl/EnsemblRestClient.java index f8cd0d6..11a869e 100644 --- a/src/jalview/ext/ensembl/EnsemblRestClient.java +++ b/src/jalview/ext/ensembl/EnsemblRestClient.java @@ -208,6 +208,11 @@ abstract class EnsemblRestClient extends EnsemblSequenceFetcher URL url = getUrl(ids); BufferedReader reader = getHttpResponse(url, ids); + if (reader == null) + { + // request failed + return null; + } FileParse fp = new FileParse(reader, url.toString(), "HTTP_POST"); return fp; } @@ -256,9 +261,8 @@ abstract class EnsemblRestClient extends EnsemblSequenceFetcher * note: a GET request for an invalid id returns an error code e.g. 415 * but POST request returns 200 and an empty Fasta response */ - throw new IOException( - "Response code was not 200. Detected response was " - + responseCode); + System.err.println("Response code " + responseCode + " for " + url); + return null; } // get content InputStream response = connection.getInputStream(); diff --git a/src/jalview/ext/ensembl/EnsemblSeqProxy.java b/src/jalview/ext/ensembl/EnsemblSeqProxy.java index c749b94..91b09ea 100644 --- a/src/jalview/ext/ensembl/EnsemblSeqProxy.java +++ b/src/jalview/ext/ensembl/EnsemblSeqProxy.java @@ -384,6 +384,11 @@ public abstract class EnsemblSeqProxy extends EnsemblRestClient throw new JalviewException("ENSEMBL Rest API not available."); } FileParse fp = getSequenceReader(ids); + if (fp == null) + { + return alignment; + } + FastaFile fr = new FastaFile(fp); if (fr.hasWarningMessage()) {