From c810eb34827563f43c265fd88981c952f3803a99 Mon Sep 17 00:00:00 2001 From: gmungoc Date: Thu, 8 Oct 2015 10:51:42 +0100 Subject: [PATCH] JAL-1499 consistent use of FileFormatException --- src/jalview/io/MegaFile.java | 37 ++++++++++++++++++++++--------------- 1 file changed, 22 insertions(+), 15 deletions(-) diff --git a/src/jalview/io/MegaFile.java b/src/jalview/io/MegaFile.java index 97d7775..fcb7a93 100644 --- a/src/jalview/io/MegaFile.java +++ b/src/jalview/io/MegaFile.java @@ -659,9 +659,9 @@ public class MegaFile extends AlignFile * Comments in MEGA are within [ ] brackets, and may be nested. * * @return - * @throws IOException + * @throws FileFormatException */ - protected String nextNonCommentLine() throws IOException + protected String nextNonCommentLine() throws FileFormatException { return nextNonCommentLine(0); } @@ -675,12 +675,19 @@ public class MegaFile extends AlignFile * @param depth * current depth of nesting of comments while parsing * @return - * @throws IOException + * @throws FileFormatException */ - protected String nextNonCommentLine(final int depth) throws IOException + protected String nextNonCommentLine(final int depth) + throws FileFormatException { String data = null; - data = nextLine(); + try + { + data = nextLine(); + } catch (IOException e) + { + throw new FileFormatException(e.getMessage()); + } if (data == null) { if (depth > 0) @@ -817,10 +824,10 @@ public class MegaFile extends AlignFile * * @param dataLine * @return - * @throws IOException + * @throws FileFormatException */ protected String parseDataLine(String dataLine) - throws IOException + throws FileFormatException { String seqId = getSequenceId(dataLine); if (seqId == null) @@ -853,7 +860,7 @@ public class MegaFile extends AlignFile * a new one if we haven't seen it before. * * @param dataLine - * @throws IOException + * @throws FileFormatException */ protected void parseNoninterleavedDataLine(String dataLine) throws FileFormatException @@ -1021,9 +1028,9 @@ public class MegaFile extends AlignFile * Save as alignment properties in case useful. * * @return the next non-blank line following the header lines. - * @throws IOException + * @throws FileFormatException */ - protected String parseHeaderLines() throws IOException + protected String parseHeaderLines() throws FileFormatException { String inputLine = null; while ((inputLine = nextNonCommentLine()) != null) @@ -1075,9 +1082,9 @@ public class MegaFile extends AlignFile * semicolon. * * @param inputLine - * @throws IOException + * @throws FileFormatException */ - protected void parseFormat(String inputLine) throws IOException + protected void parseFormat(String inputLine) throws FileFormatException { while (inputLine != null) { @@ -1292,10 +1299,10 @@ public class MegaFile extends AlignFile * Reads lines until terminated by semicolon, appending each to the * Description property value. * - * @throws IOException + * @throws FileFormatException */ protected void parseDescription(String firstDescriptionLine) - throws IOException + throws FileFormatException { StringBuilder desc = new StringBuilder(256); desc.append(getValue(firstDescriptionLine)); @@ -1588,7 +1595,7 @@ public class MegaFile extends AlignFile * * @param isIt * @param dataLine - * @throws IOException + * @throws FileFormatException */ protected void assertInterleaved(boolean isIt, String dataLine) throws FileFormatException -- 1.7.10.2