X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fio%2FHtmlFile.java;fp=src%2Fjalview%2Fio%2FHtmlFile.java;h=a4e9bf4bb15b024746f52691ca8d39086f73e811;hb=263ae64817c7604150961e1c9c76554936ab994b;hp=e847c589747b66627f384c2b9dd641c0d2912180;hpb=93d63f3c608771bb48b5ac18f761194a1ea28554;p=jalview.git diff --git a/src/jalview/io/HtmlFile.java b/src/jalview/io/HtmlFile.java index e847c58..a4e9bf4 100644 --- a/src/jalview/io/HtmlFile.java +++ b/src/jalview/io/HtmlFile.java @@ -67,15 +67,23 @@ public class HtmlFile extends AlignFile implements ComplexAlignFile { try { - StringBuilder htmlData = new StringBuilder(); - String currentLine; - while ((currentLine = nextLine()) != null) - { - htmlData.append(currentLine); + Element content = null; + Document doc = null; + try { + StringBuilder htmlData = new StringBuilder(); + String currentLine; + while ((currentLine = nextLine()) != null) + { + htmlData.append(currentLine); + } + + doc = Jsoup.parse(htmlData.toString()); + } catch (OutOfMemoryError oom) { + errormessage = "Not enough memory to process HTML document"; + throw new IOException(errormessage); } - - Document doc = Jsoup.parse(htmlData.toString()); - Element content = doc.getElementById("seqData"); + content = doc.getElementById("seqData"); + JSONFile jsonFile = new JSONFile().parse(new StringReader(content.val())); this.seqs = jsonFile.getSeqs(); this.seqGroups = jsonFile.getSeqGroups(); @@ -86,7 +94,8 @@ public class HtmlFile extends AlignFile implements ComplexAlignFile this.columnSelection = jsonFile.getColumnSelection(); } catch (Exception e) { - e.printStackTrace(); + errormessage = "Failed to extract data from HTML document."; + throw new IOException("Unexpected exception whilst extracting JSon from HTML.",e); } }