From c3939dcb98ab76b1acb6045065c46c82511f5aae Mon Sep 17 00:00:00 2001 From: Reinhard Pointner Date: Tue, 10 Feb 2009 21:51:02 +0000 Subject: [PATCH] * slightly improved exception handling --- .../filebot/ui/AbstractSearchPanel.java | 4 ++-- .../filebot/ui/NotificationLoggingHandler.java | 3 ++- .../filebot/ui/panel/analyze/FileTree.java | 4 +++- .../analyze/FileTreeTransferablePolicy.java | 3 ++- .../filebot/ui/panel/analyze/Tool.java | 6 ++++-- .../filebot/ui/panel/rename/RenameAction.java | 3 ++- .../filebot/ui/panel/rename/RenamePanel.java | 3 ++- .../ui/panel/sfv/ChecksumTableCellRenderer.java | 4 +++- .../ui/panel/sfv/SfvTransferablePolicy.java | 2 +- .../sourceforge/tuned/ExceptionUtilities.java | 16 ++++++++++++++++ 10 files changed, 37 insertions(+), 11 deletions(-) diff --git a/source/net/sourceforge/filebot/ui/AbstractSearchPanel.java b/source/net/sourceforge/filebot/ui/AbstractSearchPanel.java index 6495af87..b88a5ce3 100644 --- a/source/net/sourceforge/filebot/ui/AbstractSearchPanel.java +++ b/source/net/sourceforge/filebot/ui/AbstractSearchPanel.java @@ -184,7 +184,7 @@ public abstract class AbstractSearchPanel extends FileBotPanel { } catch (Exception e) { tab.close(); - Logger.getLogger("ui").log(Level.WARNING, ExceptionUtilities.getRootCause(e).getMessage(), e); + Logger.getLogger("ui").log(Level.WARNING, ExceptionUtilities.getRootCauseMessage(e), e); } } @@ -240,7 +240,7 @@ public abstract class AbstractSearchPanel extends FileBotPanel { } catch (Exception e) { tab.close(); - Logger.getLogger("ui").log(Level.WARNING, ExceptionUtilities.getRootCause(e).getMessage(), e); + Logger.getLogger("ui").log(Level.WARNING, ExceptionUtilities.getRootCauseMessage(e), e); } finally { tab.setLoading(false); } diff --git a/source/net/sourceforge/filebot/ui/NotificationLoggingHandler.java b/source/net/sourceforge/filebot/ui/NotificationLoggingHandler.java index 1aac7598..a891c14c 100644 --- a/source/net/sourceforge/filebot/ui/NotificationLoggingHandler.java +++ b/source/net/sourceforge/filebot/ui/NotificationLoggingHandler.java @@ -14,6 +14,7 @@ import javax.swing.Icon; import javax.swing.SwingUtilities; import net.sourceforge.filebot.ResourceManager; +import net.sourceforge.tuned.ExceptionUtilities; import net.sourceforge.tuned.ui.notification.MessageNotification; import net.sourceforge.tuned.ui.notification.NotificationManager; import net.sourceforge.tuned.ui.notification.QueueNotificationLayout; @@ -61,7 +62,7 @@ public class NotificationLoggingHandler extends Handler { if (message == null || message.isEmpty()) { // if message is empty, display exception string - message = record.getThrown().toString(); + return ExceptionUtilities.getMessage(record.getThrown()); } return message; diff --git a/source/net/sourceforge/filebot/ui/panel/analyze/FileTree.java b/source/net/sourceforge/filebot/ui/panel/analyze/FileTree.java index 898abf7e..53d67ad7 100644 --- a/source/net/sourceforge/filebot/ui/panel/analyze/FileTree.java +++ b/source/net/sourceforge/filebot/ui/panel/analyze/FileTree.java @@ -18,6 +18,7 @@ import java.util.Iterator; import java.util.LinkedHashSet; import java.util.List; import java.util.Set; +import java.util.logging.Level; import java.util.logging.Logger; import javax.swing.AbstractAction; @@ -31,6 +32,7 @@ import javax.swing.tree.TreePath; import javax.swing.tree.TreeSelectionModel; import net.sourceforge.filebot.ResourceManager; +import net.sourceforge.tuned.ExceptionUtilities; import net.sourceforge.tuned.FilterIterator; import net.sourceforge.tuned.TreeIterator; @@ -158,7 +160,7 @@ public class FileTree extends JTree { Desktop.getDesktop().open(file); } } catch (Exception e) { - Logger.getLogger("ui").warning(e.getMessage()); + Logger.getLogger("ui").log(Level.WARNING, ExceptionUtilities.getRootCauseMessage(e), e); } } } diff --git a/source/net/sourceforge/filebot/ui/panel/analyze/FileTreeTransferablePolicy.java b/source/net/sourceforge/filebot/ui/panel/analyze/FileTreeTransferablePolicy.java index aaced2c9..fd0a0f44 100644 --- a/source/net/sourceforge/filebot/ui/panel/analyze/FileTreeTransferablePolicy.java +++ b/source/net/sourceforge/filebot/ui/panel/analyze/FileTreeTransferablePolicy.java @@ -4,6 +4,7 @@ package net.sourceforge.filebot.ui.panel.analyze; import java.io.File; import java.util.List; +import java.util.logging.Level; import java.util.logging.Logger; import net.sourceforge.filebot.ui.panel.analyze.FileTree.AbstractTreeNode; @@ -50,7 +51,7 @@ class FileTreeTransferablePolicy extends BackgroundFileTransferablePolicy extends JComponent { try { setModel(get()); } catch (Exception e) { - if (ExceptionUtilities.getRootCause(e) instanceof ConcurrentModificationException) { + Throwable cause = ExceptionUtilities.getRootCause(e); + + if (cause instanceof ConcurrentModificationException || cause instanceof InterruptedException) { // if it happens, it is supposed to } else { // should not happen - Logger.getLogger("global").log(Level.WARNING, e.toString(), e); + Logger.getLogger("global").log(Level.WARNING, e.getMessage(), e); } } } diff --git a/source/net/sourceforge/filebot/ui/panel/rename/RenameAction.java b/source/net/sourceforge/filebot/ui/panel/rename/RenameAction.java index 0cca5b10..519d88a8 100644 --- a/source/net/sourceforge/filebot/ui/panel/rename/RenameAction.java +++ b/source/net/sourceforge/filebot/ui/panel/rename/RenameAction.java @@ -13,6 +13,7 @@ import javax.swing.AbstractAction; import net.sourceforge.filebot.ResourceManager; import net.sourceforge.filebot.similarity.Match; +import net.sourceforge.tuned.ExceptionUtilities; import net.sourceforge.tuned.FileUtilities; @@ -68,7 +69,7 @@ class RenameAction extends AbstractAction { Logger.getLogger("ui").info(String.format("%d files renamed.", renameCount)); } catch (IOException e) { // rename failed - Logger.getLogger("ui").warning(e.getMessage()); + Logger.getLogger("ui").warning(ExceptionUtilities.getRootCauseMessage(e)); boolean revertFailed = false; diff --git a/source/net/sourceforge/filebot/ui/panel/rename/RenamePanel.java b/source/net/sourceforge/filebot/ui/panel/rename/RenamePanel.java index cc9a52b6..4720c06f 100644 --- a/source/net/sourceforge/filebot/ui/panel/rename/RenamePanel.java +++ b/source/net/sourceforge/filebot/ui/panel/rename/RenamePanel.java @@ -10,6 +10,7 @@ import java.awt.event.ActionEvent; import java.io.File; import java.util.ArrayList; import java.util.List; +import java.util.logging.Level; import java.util.logging.Logger; import javax.swing.AbstractAction; @@ -214,7 +215,7 @@ public class RenamePanel extends FileBotPanel { model.names().addAll(names); model.files().addAll(files); } catch (Exception e) { - Logger.getLogger("ui").warning(ExceptionUtilities.getRootCause(e).getMessage()); + Logger.getLogger("ui").log(Level.WARNING, ExceptionUtilities.getRootCauseMessage(e), e); } } }; diff --git a/source/net/sourceforge/filebot/ui/panel/sfv/ChecksumTableCellRenderer.java b/source/net/sourceforge/filebot/ui/panel/sfv/ChecksumTableCellRenderer.java index 9d1f236b..705892d4 100644 --- a/source/net/sourceforge/filebot/ui/panel/sfv/ChecksumTableCellRenderer.java +++ b/source/net/sourceforge/filebot/ui/panel/sfv/ChecksumTableCellRenderer.java @@ -13,6 +13,8 @@ import javax.swing.border.EmptyBorder; import javax.swing.table.DefaultTableCellRenderer; import javax.swing.table.TableCellRenderer; +import net.sourceforge.tuned.ExceptionUtilities; + class ChecksumTableCellRenderer extends DefaultTableCellRenderer { @@ -34,7 +36,7 @@ class ChecksumTableCellRenderer extends DefaultTableCellRenderer { setText("Pending ..."); break; case ERROR: - setText(checksum.getError().getMessage()); + setText(ExceptionUtilities.getMessage(checksum.getError())); break; default: return progressBarRenderer.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column); diff --git a/source/net/sourceforge/filebot/ui/panel/sfv/SfvTransferablePolicy.java b/source/net/sourceforge/filebot/ui/panel/sfv/SfvTransferablePolicy.java index cca50efe..b87caab6 100644 --- a/source/net/sourceforge/filebot/ui/panel/sfv/SfvTransferablePolicy.java +++ b/source/net/sourceforge/filebot/ui/panel/sfv/SfvTransferablePolicy.java @@ -55,7 +55,7 @@ class SfvTransferablePolicy extends BackgroundFileTransferablePolicy