From 0da9e28329178f81f0f8341784583ce24378f0f0 Mon Sep 17 00:00:00 2001 From: "Silas S. Brown" Date: Sat, 24 May 2025 21:13:53 +0100 Subject: [PATCH] fix #18: use toString, because getMessage can be null even in JDK 24 ("it's insane right?") --- .gitignore | 3 ++ .../AccessAccessionMappingDatabase.java | 0 .../CreateAccessionMappingDatabase.java | 0 .../ModifyAccessionMappingDatabase.java | 0 .../algorithms/AssignmentUsingBestHit.java | 2 +- src/megan/algorithms/DataProcessor.java | 2 +- .../commands/ExportAlignmentCommand.java | 2 +- .../commands/ExportConsensusCommand.java | 2 +- .../commands/ExportOverlapGraphCommand.java | 2 +- .../commands/ExportReferenceCommand.java | 2 +- src/megan/blastclient/RemoteBlastDialog.java | 2 +- .../chart/commands/ExportDataCommand.java | 2 +- .../chart/drawers/CoOccurrenceToolBar.java | 2 +- src/megan/classification/Classification.java | 2 +- .../LoadMappingFile4ViewerCommand.java | 2 +- src/megan/commands/MeganizeDAACommand.java | 4 +-- src/megan/commands/SetWindowSizeCommand.java | 2 +- .../additional/RunBlastOnNCBICommand.java | 2 +- .../ExportTaxonParentMappingCommand.java | 2 +- src/megan/core/Director.java | 2 +- .../dialogs/attributes/AttributeData.java | 2 +- src/megan/dialogs/compare/Comparer.java | 2 +- .../commands/ExportSelectedCommand.java | 2 +- .../commands/ListContaminantsCommand.java | 2 +- .../commands/ChooseReadsFileCommand.java | 2 +- .../commands/ListContaminantsCommand.java | 2 +- src/megan/inspector/Loader.java | 2 +- src/megan/io/InputOutputReaderWriter.java | 2 +- src/megan/io/InputReader.java | 4 +-- src/megan/main/Megan6.java | 2 +- src/megan/ms/server/RequestHandler.java | 28 +++++++++---------- .../ms/server/RequestHandlerAdditional.java | 2 +- src/megan/ms/server/RequestHandlerAdmin.java | 16 +++++------ .../parsers/blast/BlastN2SAMIterator.java | 2 +- .../parsers/blast/BlastTab2SAMIterator.java | 2 +- .../parsers/blast/BlastX2SAMIterator.java | 2 +- .../parsers/blast/BlastXML2SAMIterator.java | 2 +- .../parsers/blast/LastMAF2SAMIterator.java | 2 +- src/megan/parsers/blast/SAM2SAMIterator.java | 2 +- src/megan/rma6/ReadBlockRMA6.java | 2 +- src/megan/samplesviewer/SamplesTableView.java | 8 +++--- src/megan/tools/ReadExtractorTool.java | 2 +- ...ExportFrameShiftCorrectedReadsCommand.java | 2 +- .../ExportSegmentationOfReadsCommand.java | 4 +-- src/megan/viewer/commands/PrintCommand.java | 2 +- 45 files changed, 70 insertions(+), 67 deletions(-) mode change 100755 => 100644 src/megan/accessiondb/AccessAccessionMappingDatabase.java mode change 100755 => 100644 src/megan/accessiondb/CreateAccessionMappingDatabase.java mode change 100755 => 100644 src/megan/accessiondb/ModifyAccessionMappingDatabase.java diff --git a/.gitignore b/.gitignore index 70b2a0c3c..abeecbab2 100644 --- a/.gitignore +++ b/.gitignore @@ -38,6 +38,9 @@ antbuild/ .classpath .project +#emacs +*~ + # LaTeX auxiliary files *.aux *.blg diff --git a/src/megan/accessiondb/AccessAccessionMappingDatabase.java b/src/megan/accessiondb/AccessAccessionMappingDatabase.java old mode 100755 new mode 100644 diff --git a/src/megan/accessiondb/CreateAccessionMappingDatabase.java b/src/megan/accessiondb/CreateAccessionMappingDatabase.java old mode 100755 new mode 100644 diff --git a/src/megan/accessiondb/ModifyAccessionMappingDatabase.java b/src/megan/accessiondb/ModifyAccessionMappingDatabase.java old mode 100755 new mode 100644 diff --git a/src/megan/algorithms/AssignmentUsingBestHit.java b/src/megan/algorithms/AssignmentUsingBestHit.java index 92c1babbe..265168814 100644 --- a/src/megan/algorithms/AssignmentUsingBestHit.java +++ b/src/megan/algorithms/AssignmentUsingBestHit.java @@ -112,7 +112,7 @@ private Map loadAssignmentFiles(String cName, String fileName) } } } catch (IOException ex) { - System.err.println(ex.getMessage()); + System.err.println(ex); } System.err.println("Count: " + map.size()); if (map.size() > 0) diff --git a/src/megan/algorithms/DataProcessor.java b/src/megan/algorithms/DataProcessor.java index e762f1416..7a712e097 100644 --- a/src/megan/algorithms/DataProcessor.java +++ b/src/megan/algorithms/DataProcessor.java @@ -416,7 +416,7 @@ else if (id > 0) return (int) doc.getDataTable().getTotalReads(); } catch (IOException ex) { Basic.caught(ex); - NotificationsInSwing.showInternalError("Data Processor failed: " + ex.getMessage()); + NotificationsInSwing.showInternalError("Data Processor failed: " + ex); } return 0; } diff --git a/src/megan/alignment/commands/ExportAlignmentCommand.java b/src/megan/alignment/commands/ExportAlignmentCommand.java index e32faefd9..0e40f59ec 100644 --- a/src/megan/alignment/commands/ExportAlignmentCommand.java +++ b/src/megan/alignment/commands/ExportAlignmentCommand.java @@ -77,7 +77,7 @@ public void apply(NexusStreamParser np) throws Exception { w.close(); } } catch (IOException e) { - NotificationsInSwing.showError("Export Alignment failed: " + e.getMessage()); + NotificationsInSwing.showError("Export Alignment failed: " + e); } } diff --git a/src/megan/alignment/commands/ExportConsensusCommand.java b/src/megan/alignment/commands/ExportConsensusCommand.java index 070e87402..87b095095 100644 --- a/src/megan/alignment/commands/ExportConsensusCommand.java +++ b/src/megan/alignment/commands/ExportConsensusCommand.java @@ -77,7 +77,7 @@ public void apply(NexusStreamParser np) throws Exception { w.close(); } } catch (IOException e) { - NotificationsInSwing.showError("Export Consensus failed: " + e.getMessage()); + NotificationsInSwing.showError("Export Consensus failed: " + e); } } diff --git a/src/megan/alignment/commands/ExportOverlapGraphCommand.java b/src/megan/alignment/commands/ExportOverlapGraphCommand.java index 4977f0cb5..7ae3a1f19 100644 --- a/src/megan/alignment/commands/ExportOverlapGraphCommand.java +++ b/src/megan/alignment/commands/ExportOverlapGraphCommand.java @@ -83,7 +83,7 @@ public void apply(NexusStreamParser np) throws Exception { if (showGraph) alignmentAssembler.showOverlapGraph(dir, dir.getDocument().getProgressListener()); } catch (IOException e) { - NotificationsInSwing.showError("Export overlap file FAILED: " + e.getMessage()); + NotificationsInSwing.showError("Export overlap file FAILED: " + e); } } diff --git a/src/megan/alignment/commands/ExportReferenceCommand.java b/src/megan/alignment/commands/ExportReferenceCommand.java index e90bffd14..e30e9ec46 100644 --- a/src/megan/alignment/commands/ExportReferenceCommand.java +++ b/src/megan/alignment/commands/ExportReferenceCommand.java @@ -76,7 +76,7 @@ public void apply(NexusStreamParser np) throws Exception { w.close(); } } catch (IOException e) { - NotificationsInSwing.showError("Export Reference failed: " + e.getMessage()); + NotificationsInSwing.showError("Export Reference failed: " + e); } } diff --git a/src/megan/blastclient/RemoteBlastDialog.java b/src/megan/blastclient/RemoteBlastDialog.java index df8af0e13..277c29179 100644 --- a/src/megan/blastclient/RemoteBlastDialog.java +++ b/src/megan/blastclient/RemoteBlastDialog.java @@ -229,7 +229,7 @@ public void actionPerformed(ActionEvent e) { break; } } catch (IOException ex) { - NotificationsInSwing.showError("Write file failed: " + ex.getMessage()); + NotificationsInSwing.showError("Write file failed: " + ex); return; } System.err.println("Reads written to: " + readsFile); diff --git a/src/megan/chart/commands/ExportDataCommand.java b/src/megan/chart/commands/ExportDataCommand.java index 064b585a9..5e57bac44 100644 --- a/src/megan/chart/commands/ExportDataCommand.java +++ b/src/megan/chart/commands/ExportDataCommand.java @@ -59,7 +59,7 @@ public void apply(NexusStreamParser np) throws Exception { chartViewer.getChartDrawer().writeData(w); w.close(); } catch (IOException e) { - NotificationsInSwing.showError("Export Data failed: " + e.getMessage()); + NotificationsInSwing.showError("Export Data failed: " + e); } } diff --git a/src/megan/chart/drawers/CoOccurrenceToolBar.java b/src/megan/chart/drawers/CoOccurrenceToolBar.java index 6c17131a0..c0987adda 100644 --- a/src/megan/chart/drawers/CoOccurrenceToolBar.java +++ b/src/megan/chart/drawers/CoOccurrenceToolBar.java @@ -205,7 +205,7 @@ public void actionPerformed(ActionEvent actionEvent) { chartViewer.getDir().execute("show what=all target=classes;", chartViewer.getCommandManager()); } catch (Exception ex) { - NotificationsInSwing.showInternalError(chartViewer.getFrame(), "CoOccurrence drawer: " + ex.getMessage()); + NotificationsInSwing.showInternalError(chartViewer.getFrame(), "CoOccurrence drawer: " + ex); } } }); diff --git a/src/megan/classification/Classification.java b/src/megan/classification/Classification.java index c6d545fe7..8a84937eb 100644 --- a/src/megan/classification/Classification.java +++ b/src/megan/classification/Classification.java @@ -89,7 +89,7 @@ public void load(String treeFile, String mapFile, ProgressListener progress) { progress.setProgress(2); } catch (Exception e) { Basic.caught(e); - NotificationsInSwing.showError(MainViewer.getLastActiveFrame(), "Failed to open files: " + treeFile + " and " + mapFile + ": " + e.getMessage()); + NotificationsInSwing.showError(MainViewer.getLastActiveFrame(), "Failed to open files: " + treeFile + " and " + mapFile + ": " + e); } finally { progress.setCancelable(true); } diff --git a/src/megan/classification/commandtemplates/LoadMappingFile4ViewerCommand.java b/src/megan/classification/commandtemplates/LoadMappingFile4ViewerCommand.java index 195b00594..7bb5a0776 100644 --- a/src/megan/classification/commandtemplates/LoadMappingFile4ViewerCommand.java +++ b/src/megan/classification/commandtemplates/LoadMappingFile4ViewerCommand.java @@ -99,7 +99,7 @@ public void actionPerformed(ActionEvent ev) { ClassificationManager.setMeganMapDBFile(file.toString()); ClassificationManager.setUseFastAccessionMappingMode(true); } catch (IOException e) { - NotificationsInSwing.showError("Load MEGAN mapping db failed: " + e.getMessage()); + NotificationsInSwing.showError("Load MEGAN mapping db failed: " + e); return; } final Collection supportedClassifications = AccessAccessionMappingDatabase.getContainedClassificationsIfDBExists(file.getPath()); diff --git a/src/megan/commands/MeganizeDAACommand.java b/src/megan/commands/MeganizeDAACommand.java index 561541d2e..293439e0d 100644 --- a/src/megan/commands/MeganizeDAACommand.java +++ b/src/megan/commands/MeganizeDAACommand.java @@ -282,8 +282,8 @@ public void apply(NexusStreamParser np) throws Exception { } catch (CanceledException ex) { throw ex; } catch (Exception ex) { - NotificationsInSwing.showError(ex.getMessage()); - System.err.println(ex.getMessage()); + NotificationsInSwing.showError(ex.toString()); + System.err.println(ex); countFailed++; } } diff --git a/src/megan/commands/SetWindowSizeCommand.java b/src/megan/commands/SetWindowSizeCommand.java index 6219d9171..ea737ee18 100644 --- a/src/megan/commands/SetWindowSizeCommand.java +++ b/src/megan/commands/SetWindowSizeCommand.java @@ -59,7 +59,7 @@ public void actionPerformed(ActionEvent event) { throw new NumberFormatException("Unexpected characters at end of string"); execute("set windowSize=" + width + " x " + height + ";"); } catch (NumberFormatException e) { - NotificationsInSwing.showError("Window Size: Invalid entry: " + e.getMessage()); + NotificationsInSwing.showError("Window Size: Invalid entry: " + e.toString()); } } } diff --git a/src/megan/commands/additional/RunBlastOnNCBICommand.java b/src/megan/commands/additional/RunBlastOnNCBICommand.java index 9580ab206..cd273502c 100644 --- a/src/megan/commands/additional/RunBlastOnNCBICommand.java +++ b/src/megan/commands/additional/RunBlastOnNCBICommand.java @@ -193,7 +193,7 @@ public void apply(NexusStreamParser np) throws Exception { } } } catch (Exception ex) { - NotificationsInSwing.showError("Create RMA file failed: " + ex.getMessage()); + NotificationsInSwing.showError("Create RMA file failed: " + ex); getDir().notifyUnlockInput(); getDir().executeImmediately("close what=current;", ((Director) getDir()).getCommandManager()); } diff --git a/src/megan/commands/export/ExportTaxonParentMappingCommand.java b/src/megan/commands/export/ExportTaxonParentMappingCommand.java index 5829d8354..8908b1a6d 100644 --- a/src/megan/commands/export/ExportTaxonParentMappingCommand.java +++ b/src/megan/commands/export/ExportTaxonParentMappingCommand.java @@ -101,7 +101,7 @@ public void apply(NexusStreamParser np) throws Exception { exception.setIfCurrentValueIsNull(ex); } if(exception.isNotNull()) { - NotificationsInSwing.showError("Write failed: "+exception.get().getMessage()); + NotificationsInSwing.showError("Write failed: "+exception.get()); } } diff --git a/src/megan/core/Director.java b/src/megan/core/Director.java index 3732f02f3..a85187396 100644 --- a/src/megan/core/Director.java +++ b/src/megan/core/Director.java @@ -286,7 +286,7 @@ public boolean executeImmediately(final String command, CommandManager commandMa return false; } catch (Exception ex) { - NotificationsInSwing.showError("Command failed: " + ex.getMessage()); + NotificationsInSwing.showError("Command failed: " + ex); return false; } } diff --git a/src/megan/dialogs/attributes/AttributeData.java b/src/megan/dialogs/attributes/AttributeData.java index 0b10bef21..b48901af2 100644 --- a/src/megan/dialogs/attributes/AttributeData.java +++ b/src/megan/dialogs/attributes/AttributeData.java @@ -79,7 +79,7 @@ private AttributeData(String filename) { System.err.println("done (" + attribute2kind2taxaNames.size() + ")"); } catch (IOException e) { Basic.caught(e); - NotificationsInSwing.showError(MainViewer.getLastActiveFrame(), "Init failed: " + e.getMessage()); + NotificationsInSwing.showError(MainViewer.getLastActiveFrame(), "Init failed: " + e); } setTaxaAttributes(); setAttributes2Properties(); diff --git a/src/megan/dialogs/compare/Comparer.java b/src/megan/dialogs/compare/Comparer.java index 0c1a3b4d9..6c0f30fad 100644 --- a/src/megan/dialogs/compare/Comparer.java +++ b/src/megan/dialogs/compare/Comparer.java @@ -267,7 +267,7 @@ else if (useRelative) { service.shutdownNow(); } if(exception.isNotNull()) - throw new IOException("Comparison computation failed: " + exception.get().getMessage(), exception.get()); + throw new IOException("Comparison computation failed: " + exception.get(), exception.get()); // if we have a taxonomy classification, then use it to get exact values: if (result.getClassification2Class2Counts().containsKey(Classification.Taxonomy)) { diff --git a/src/megan/dialogs/lrinspector/commands/ExportSelectedCommand.java b/src/megan/dialogs/lrinspector/commands/ExportSelectedCommand.java index 95ebfdbad..09de6a50a 100644 --- a/src/megan/dialogs/lrinspector/commands/ExportSelectedCommand.java +++ b/src/megan/dialogs/lrinspector/commands/ExportSelectedCommand.java @@ -54,7 +54,7 @@ public void apply(NexusStreamParser np) throws Exception { FileUtils.writeStreamToFile(new ByteInputStream(selection, selection.length), new File(fileName)); NotificationsInSwing.showInformation("Exported " + StringUtils.countOccurrences(selection, '\n') + " lines to file: " + fileName); } catch (IOException ex) { - NotificationsInSwing.showError("Export failed: " + ex.getMessage()); + NotificationsInSwing.showError("Export failed: " + ex); } } } diff --git a/src/megan/dialogs/parameters/commands/ListContaminantsCommand.java b/src/megan/dialogs/parameters/commands/ListContaminantsCommand.java index af13b5d5c..a4a4a0b6b 100644 --- a/src/megan/dialogs/parameters/commands/ListContaminantsCommand.java +++ b/src/megan/dialogs/parameters/commands/ListContaminantsCommand.java @@ -69,7 +69,7 @@ public void actionPerformed(ActionEvent ev) { executeImmediately("show window=message; list taxa=" + contaminantManager.getTaxonIdsString() + " title='Contaminants';"); } catch (IOException e) { - NotificationsInSwing.showWarning("Read contaminant file failed: " + e.getMessage()); + NotificationsInSwing.showWarning("Read contaminant file failed: " + e); } } } diff --git a/src/megan/importblast/commands/ChooseReadsFileCommand.java b/src/megan/importblast/commands/ChooseReadsFileCommand.java index 23b046162..ea5481193 100644 --- a/src/megan/importblast/commands/ChooseReadsFileCommand.java +++ b/src/megan/importblast/commands/ChooseReadsFileCommand.java @@ -83,7 +83,7 @@ public void actionPerformed(ActionEvent event) { importBlastDialog.setReadFileName(StringUtils.toString(files, "\n")); importBlastDialog.getReadFileNameField().setText(StringUtils.toString(files, "\n")); } catch (IOException ex) { - NotificationsInSwing.showError(getViewer().getFrame(), "Failed to load file: " + ex.getMessage()); + NotificationsInSwing.showError(getViewer().getFrame(), "Failed to load file: " + ex); } } } diff --git a/src/megan/importblast/commands/ListContaminantsCommand.java b/src/megan/importblast/commands/ListContaminantsCommand.java index 167cc1afe..4f23d24a4 100644 --- a/src/megan/importblast/commands/ListContaminantsCommand.java +++ b/src/megan/importblast/commands/ListContaminantsCommand.java @@ -65,7 +65,7 @@ public void actionPerformed(ActionEvent ev) { contaminantManager.read(((ImportBlastDialog) getViewer()).getContaminantsFileName()); } catch (IOException e) { NotificationsInSwing.showError("Failed to parse file: " + ((ImportBlastDialog) getViewer()).getContaminantsFileName() - + ":\n" + e.getMessage()); + + ":\n" + e); } executeImmediately("show window=message;list taxa=" + contaminantManager.getTaxonIdsString() + " title='Contaminants';"); } diff --git a/src/megan/inspector/Loader.java b/src/megan/inspector/Loader.java index e04e8c7dd..266e861d9 100644 --- a/src/megan/inspector/Loader.java +++ b/src/megan/inspector/Loader.java @@ -78,7 +78,7 @@ private void processQueue() { // System.err.println("USER CANCELED EXECUTE"); } catch (Exception ex) { Basic.caught(ex); - NotificationsInSwing.showError(inspectorWindow.getFrame(), "Load data failed: " + ex.getMessage()); + NotificationsInSwing.showError(inspectorWindow.getFrame(), "Load data failed: " + ex); } } } finally { diff --git a/src/megan/io/InputOutputReaderWriter.java b/src/megan/io/InputOutputReaderWriter.java index 9cb469930..e3b5388f0 100644 --- a/src/megan/io/InputOutputReaderWriter.java +++ b/src/megan/io/InputOutputReaderWriter.java @@ -100,7 +100,7 @@ public String readString() throws IOException { try { return compressor.inflateByteArray2String(-size, bytes); } catch (DataFormatException e) { - throw new IOException(e.getMessage()); + throw new IOException(e.toString()); } } else { return Compressor.convertUncompressedByteArray2String(size, bytes); diff --git a/src/megan/io/InputReader.java b/src/megan/io/InputReader.java index c7ff3f1ab..84e922f4a 100644 --- a/src/megan/io/InputReader.java +++ b/src/megan/io/InputReader.java @@ -155,7 +155,7 @@ public String readString() throws IOException { try { return compressor.inflateByteArray2String(-size, bytes); } catch (DataFormatException e) { - throw new IOException(e.getMessage()); + throw new IOException(e.toString()); } } else { return Compressor.convertUncompressedByteArray2String(size, bytes); @@ -183,7 +183,7 @@ public int readString(byte[] tmp, byte[] target) throws IOException { try { return compressor.inflateByteArray(size, tmp, target); } catch (DataFormatException e) { - throw new IOException(e.getMessage()); + throw new IOException(e.toString()); } } } diff --git a/src/megan/main/Megan6.java b/src/megan/main/Megan6.java index 29726e2ae..4ec2904ec 100644 --- a/src/megan/main/Megan6.java +++ b/src/megan/main/Megan6.java @@ -83,7 +83,7 @@ public static void main(String[] args) { } catch (Throwable th) { //catch any exceptions and the like that propagate up to the top level - if (!th.getMessage().equals("Help")) { + if (!"Help".equals(th.getMessage())) { System.err.println("MEGAN fatal error:" + "\n" + th); Basic.caught(th); System.exit(1); diff --git a/src/megan/ms/server/RequestHandler.java b/src/megan/ms/server/RequestHandler.java index 12d3bdcb1..9f4314f6a 100644 --- a/src/megan/ms/server/RequestHandler.java +++ b/src/megan/ms/server/RequestHandler.java @@ -69,7 +69,7 @@ static RequestHandler getHelp(String url) { } throw new IOException("Resource not found: ms/help.html"); } catch (IOException ex) { - return reportError(c, p, ex.getMessage()); + return reportError(c, p, ex.toString()); } }; } @@ -80,7 +80,7 @@ static RequestHandler getVersion() { checkKnownParameters(p); return MeganServer.Version.getBytes(); } catch (IOException ex) { - return reportError(c, p, ex.getMessage()); + return reportError(c, p, ex.toString()); } }; } @@ -108,7 +108,7 @@ static RequestHandler getListDataset(Database database) { } return StringUtils.toString(list, "\n").getBytes(); } catch (IOException ex) { - return reportError(c, p, ex.getMessage()); + return reportError(c, p, ex.toString()); } }; } @@ -125,7 +125,7 @@ static RequestHandler getNumberOfReads(Database database) { } return StringUtils.toString(list, " ").getBytes(); } catch (IOException ex) { - return reportError(c, p, ex.getMessage()); + return reportError(c, p, ex.toString()); } }; } @@ -142,7 +142,7 @@ static RequestHandler getNumberOfMatches(Database database) { } return StringUtils.toString(list, " ").getBytes(); } catch (IOException ex) { - return reportError(c, p, ex.getMessage()); + return reportError(c, p, ex.toString()); } }; } @@ -159,7 +159,7 @@ static RequestHandler getClassifications(Database database) { } return StringUtils.toString(list, "\n").getBytes(); } catch (IOException ex) { - return reportError(c, p, ex.getMessage()); + return reportError(c, p, ex.toString()); } }; } @@ -186,7 +186,7 @@ static RequestHandler getAuxiliaryData(Database database) { } return StringUtils.toString(list, "\n").getBytes(); } catch (IOException ex) { - return reportError(c, p, ex.getMessage()); + return reportError(c, p, ex.toString()); } }; } @@ -214,7 +214,7 @@ static RequestHandler getFileUid(Database database) { } return StringUtils.toString(list, "\n").getBytes(); } catch (IOException ex) { - return reportError(c, p, ex.getMessage()); + return reportError(c, p, ex.toString()); } }; } @@ -243,7 +243,7 @@ static RequestHandler getClassificationBlock(Database database) { return StringUtils.toString(list, "\n").getBytes(); } } catch (IOException ex) { - return reportError(c, p, ex.getMessage()); + return reportError(c, p, ex.toString()); } }; } @@ -274,7 +274,7 @@ static RequestHandler getClassSize(Database database) { } return StringUtils.toString(list, "\n").getBytes(); } catch (IOException ex) { - return reportError(c, p, ex.getMessage()); + return reportError(c, p, ex.toString()); } }; } @@ -304,7 +304,7 @@ static RequestHandler getRead(Database database) { return ReadBlockMS.writeToString(database.getRead(fileName, readId, format.isMatches()), format.isReadIds(), format.isHeaders(), format.isSequences(), format.isMatches()).getBytes(); } } catch (IOException ex) { - return reportError(c, p, ex.getMessage()); + return reportError(c, p, ex.toString()); } }; } @@ -337,7 +337,7 @@ static RequestHandler getReads(Database database,int defaultReadsPerPage) { final ReadIteratorPagination.Page page = database.getReads(fileName, format, pageSize); return getReads(c, binary, page); } catch (IOException ex) { - return reportError(c, p, ex.getMessage()); + return reportError(c, p, ex.toString()); } }; } @@ -364,7 +364,7 @@ static RequestHandler getReadsForMultipleClassIdsIterator(Database database,int final ReadIteratorPagination.Page page = database.getReadsForMultipleClassIds(fileName, classification, classIds, format, pageSize); return getReads(c, binary, page); } catch (IOException ex) { - return reportError(c, p, ex.getMessage()); + return reportError(c, p, ex.toString()); } }; } @@ -382,7 +382,7 @@ static RequestHandler getNextPage(Database database) { final ReadIteratorPagination.Page page = database.getNextPage(pageId, pageSize); return getReads(c, binary, page); } catch (IOException ex) { - return reportError(c, p, ex.getMessage()); + return reportError(c, p, ex.toString()); } }; } diff --git a/src/megan/ms/server/RequestHandlerAdditional.java b/src/megan/ms/server/RequestHandlerAdditional.java index 2a960e660..210162e4c 100644 --- a/src/megan/ms/server/RequestHandlerAdditional.java +++ b/src/megan/ms/server/RequestHandlerAdditional.java @@ -44,7 +44,7 @@ static RequestHandler getDownloadPage(Database database) { final var file = database.getRecord(name).getFile(); return (DOWNLOAD_FILE_PREFIX + file).getBytes(); } catch (IOException ex) { - return RequestHandler.reportError(c, p, ex.getMessage()); + return RequestHandler.reportError(c, p, ex.toString()); } }; } diff --git a/src/megan/ms/server/RequestHandlerAdmin.java b/src/megan/ms/server/RequestHandlerAdmin.java index 78d15d585..12e6ac647 100644 --- a/src/megan/ms/server/RequestHandlerAdmin.java +++ b/src/megan/ms/server/RequestHandlerAdmin.java @@ -58,7 +58,7 @@ static RequestHandler addUser(UserManager userManager) { userManager.addUser(user, password, allowReplace, role); return ("User '" + user + "' added").getBytes(); } catch (IOException ex) { - return reportError(c, p, ex.getMessage()); + return reportError(c, p, ex.toString()); } }; } @@ -81,7 +81,7 @@ static RequestHandler addRole(UserManager userManager) { userManager.addRoles(user, roles); return ("User " + user + ": role " + StringUtils.toString(roles, ",") + " added").getBytes(); } catch (IOException ex) { - return reportError(c, p, ex.getMessage()); + return reportError(c, p, ex.toString()); } }; } @@ -104,7 +104,7 @@ static RequestHandler removeRole(UserManager userManager) { userManager.removeRoles(user, roles); return ("User " + user + ": role " + StringUtils.toString(roles, ",") + " removed").getBytes(); } catch (IOException ex) { - return reportError(c, p, ex.getMessage()); + return reportError(c, p, ex.toString()); } }; } @@ -123,7 +123,7 @@ static RequestHandler removeUser(UserManager userManager) { userManager.removeUser(user); return ("User '" + user + "' removed").getBytes(); } catch (IOException ex) { - return reportError(c, p, ex.getMessage()); + return reportError(c, p, ex.toString()); } }; } @@ -143,7 +143,7 @@ static RequestHandler update(Collection databases) { list.add(database.rebuild().getBytes()); return StringUtils.concatenate(list); } catch (IOException ex) { - return reportError(c, p, ex.getMessage()); + return reportError(c, p, ex.toString()); } finally { inUpdate.set(false); } @@ -157,7 +157,7 @@ static RequestHandler shutdown() { System.exit(0); return "Shut down".getBytes(); } catch (IOException ex) { - return reportError(c, p, ex.getMessage()); + return reportError(c, p, ex.toString()); } }; } @@ -171,7 +171,7 @@ static RequestHandler getLog() { checkKnownParameters(p); return Basic.getCollected().getBytes(); } catch (IOException ex) { - return reportError(c, p, ex.getMessage()); + return reportError(c, p, ex.toString()); } }; } @@ -187,7 +187,7 @@ static RequestHandler clearLog() { Basic.startCollectionStdErr(); return "Log cleared".getBytes(); } catch (IOException ex) { - return reportError(c, p, ex.getMessage()); + return reportError(c, p, ex.toString()); } }; } diff --git a/src/megan/parsers/blast/BlastN2SAMIterator.java b/src/megan/parsers/blast/BlastN2SAMIterator.java index b7f6b1d61..b1b74b0c0 100644 --- a/src/megan/parsers/blast/BlastN2SAMIterator.java +++ b/src/megan/parsers/blast/BlastN2SAMIterator.java @@ -218,7 +218,7 @@ public int next() { } } } catch (Exception ex) { - System.err.println("Error parsing file near line: " + getLineNumber() + ": " + ex.getMessage()); + System.err.println("Error parsing file near line: " + getLineNumber() + ": " + ex); if (incrementNumberOfErrors() >= getMaxNumberOfErrors()) throw new RuntimeException("Too many errors"); } diff --git a/src/megan/parsers/blast/BlastTab2SAMIterator.java b/src/megan/parsers/blast/BlastTab2SAMIterator.java index daec53673..9af3855e3 100644 --- a/src/megan/parsers/blast/BlastTab2SAMIterator.java +++ b/src/megan/parsers/blast/BlastTab2SAMIterator.java @@ -161,7 +161,7 @@ public int next() { } } } catch (Exception ex) { - System.err.println("Error parsing file near line: " + getLineNumber() + ": " + ex.getMessage()); + System.err.println("Error parsing file near line: " + getLineNumber() + ": " + ex); if (incrementNumberOfErrors() >= getMaxNumberOfErrors()) throw new RuntimeException("Too many errors"); } diff --git a/src/megan/parsers/blast/BlastX2SAMIterator.java b/src/megan/parsers/blast/BlastX2SAMIterator.java index a469de046..b79899de8 100644 --- a/src/megan/parsers/blast/BlastX2SAMIterator.java +++ b/src/megan/parsers/blast/BlastX2SAMIterator.java @@ -230,7 +230,7 @@ else if (isParseLongReads()) { // when parsing long reads we keep alignments bas } } } catch (Exception ex) { - System.err.println("Error parsing file near line: " + getLineNumber() + ": " + ex.getMessage()); + System.err.println("Error parsing file near line: " + getLineNumber() + ": " + ex); if (incrementNumberOfErrors() >= getMaxNumberOfErrors()) throw new RuntimeException("Too many errors"); } diff --git a/src/megan/parsers/blast/BlastXML2SAMIterator.java b/src/megan/parsers/blast/BlastXML2SAMIterator.java index 81242cd2a..10a8c2d11 100644 --- a/src/megan/parsers/blast/BlastXML2SAMIterator.java +++ b/src/megan/parsers/blast/BlastXML2SAMIterator.java @@ -69,7 +69,7 @@ public BlastXML2SAMIterator(String fileName, int maxNumberOfMatchesPerRead) { blastXMLParser.apply(); } catch (Exception e) { Basic.caught(e); - NotificationsInSwing.showError(Basic.getShortName(e.getClass()) + ": " + e.getMessage()); + NotificationsInSwing.showError(Basic.getShortName(e.getClass()) + ": " + e); } finally { try { queue.put(sentinel); diff --git a/src/megan/parsers/blast/LastMAF2SAMIterator.java b/src/megan/parsers/blast/LastMAF2SAMIterator.java index 217f518eb..dfb832910 100644 --- a/src/megan/parsers/blast/LastMAF2SAMIterator.java +++ b/src/megan/parsers/blast/LastMAF2SAMIterator.java @@ -197,7 +197,7 @@ public int next() { } } catch (Exception ex) { - System.err.println("Error parsing file near line: " + getLineNumber() + ": " + ex.getMessage()); + System.err.println("Error parsing file near line: " + getLineNumber() + ": " + ex); if (incrementNumberOfErrors() >= getMaxNumberOfErrors()) throw new RuntimeException("Too many errors"); } diff --git a/src/megan/parsers/blast/SAM2SAMIterator.java b/src/megan/parsers/blast/SAM2SAMIterator.java index 3ec1a1e76..c5dd13cbf 100644 --- a/src/megan/parsers/blast/SAM2SAMIterator.java +++ b/src/megan/parsers/blast/SAM2SAMIterator.java @@ -125,7 +125,7 @@ public int next() { } } catch (Exception ex) { - System.err.println("Error parsing file near line: " + getLineNumber() + ": " + ex.getMessage()); + System.err.println("Error parsing file near line: " + getLineNumber() + ": " + ex); if (incrementNumberOfErrors() >= getMaxNumberOfErrors()) throw new RuntimeException("Too many errors"); } diff --git a/src/megan/rma6/ReadBlockRMA6.java b/src/megan/rma6/ReadBlockRMA6.java index fb2745484..6bf8a838e 100644 --- a/src/megan/rma6/ReadBlockRMA6.java +++ b/src/megan/rma6/ReadBlockRMA6.java @@ -331,7 +331,7 @@ public void read(IInputReader reader, boolean wantReadSequence, boolean wantMatc copies[matchCount++] = matchBlock; // this match is ok, keep it } } catch (IOException ex) { - System.err.println("RMA6 Parse error: " + ex.getMessage() + ", numberOfMatches=" + numberOfMatches + ", i=" + i + " line=" + aLine); + System.err.println("RMA6 Parse error: " + ex + ", numberOfMatches=" + numberOfMatches + ", i=" + i + " line=" + aLine); } } if (matchCount < matchBlocks.length) { // some matches didn't meet the minScore or maxExpected criteria, resize diff --git a/src/megan/samplesviewer/SamplesTableView.java b/src/megan/samplesviewer/SamplesTableView.java index 2faf2e3fd..20e46393b 100644 --- a/src/megan/samplesviewer/SamplesTableView.java +++ b/src/megan/samplesviewer/SamplesTableView.java @@ -50,9 +50,9 @@ public class SamplesTableView { private static final Set seenFXExceptions = new HashSet<>(); private static final Thread.UncaughtExceptionHandler fxExceptionHandler = (t, e) -> { - if (!seenFXExceptions.contains(e.getMessage())) { - seenFXExceptions.add(e.getMessage()); - System.err.println("FX Exception: " + e.getMessage()); + if (!seenFXExceptions.contains(e.toString())) { + seenFXExceptions.add(e.toString()); + System.err.println("FX Exception: " + e); } }; @@ -394,7 +394,7 @@ public void syncFromViewToDocument() { } initialUpdate = tableView.getUpdate(); - //System.err.println("Doc: "+w.toString()); + //System.err.println("Doc: "+w); if (false) SwingUtilities.invokeLater(() -> samplesViewer.getDocument().getDir().notifyUpdateViewer(IDirector.ALL)); } diff --git a/src/megan/tools/ReadExtractorTool.java b/src/megan/tools/ReadExtractorTool.java index b449f9d1a..ddbb47dcf 100644 --- a/src/megan/tools/ReadExtractorTool.java +++ b/src/megan/tools/ReadExtractorTool.java @@ -135,7 +135,7 @@ private void run(String[] args) throws UsageException, IOException { } } catch (Exception ex) { if (ignoreExceptions) - System.err.println(Basic.getShortName(ex.getClass()) + ": " + ex.getMessage() + ", while processing file: " + inputFile); + System.err.println(Basic.getShortName(ex.getClass()) + ": " + ex + ", while processing file: " + inputFile); else throw ex; } diff --git a/src/megan/viewer/commands/ExportFrameShiftCorrectedReadsCommand.java b/src/megan/viewer/commands/ExportFrameShiftCorrectedReadsCommand.java index 64713c93a..a79337c95 100644 --- a/src/megan/viewer/commands/ExportFrameShiftCorrectedReadsCommand.java +++ b/src/megan/viewer/commands/ExportFrameShiftCorrectedReadsCommand.java @@ -63,7 +63,7 @@ public void apply(NexusStreamParser np) throws Exception { NotificationsInSwing.showInformation("Exported corrected reads: " + count); } catch (IOException e) { - NotificationsInSwing.showError("Export corrected reads failed: " + e.getMessage()); + NotificationsInSwing.showError("Export corrected reads failed: " + e); } } diff --git a/src/megan/viewer/commands/ExportSegmentationOfReadsCommand.java b/src/megan/viewer/commands/ExportSegmentationOfReadsCommand.java index e7a16c8b6..0623589a8 100644 --- a/src/megan/viewer/commands/ExportSegmentationOfReadsCommand.java +++ b/src/megan/viewer/commands/ExportSegmentationOfReadsCommand.java @@ -89,7 +89,7 @@ public void apply(NexusStreamParser np) throws Exception { NotificationsInSwing.showInformation("Exported segmentation of reads: " + count); } catch (IOException e) { - NotificationsInSwing.showError("Export segmentation of reads failed: " + e.getMessage()); + NotificationsInSwing.showError("Export segmentation of reads failed: " + e); } } @@ -206,4 +206,4 @@ public boolean isCritical() { public KeyStroke getAcceleratorKey() { return null; } -} \ No newline at end of file +} diff --git a/src/megan/viewer/commands/PrintCommand.java b/src/megan/viewer/commands/PrintCommand.java index 42cb92dbb..fd5050775 100644 --- a/src/megan/viewer/commands/PrintCommand.java +++ b/src/megan/viewer/commands/PrintCommand.java @@ -53,7 +53,7 @@ public void apply(NexusStreamParser np) throws Exception { try { job.print(); } catch (Exception ex) { - NotificationsInSwing.showError(getViewer().getFrame(), "Print failed: " + ex.getMessage()); + NotificationsInSwing.showError(getViewer().getFrame(), "Print failed: " + ex); } } }