* slightly improved exception handling
This commit is contained in:
parent
dac55956f6
commit
c3939dcb98
|
@ -184,7 +184,7 @@ public abstract class AbstractSearchPanel<S, E> extends FileBotPanel {
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
tab.close();
|
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<S, E> extends FileBotPanel {
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
tab.close();
|
tab.close();
|
||||||
|
|
||||||
Logger.getLogger("ui").log(Level.WARNING, ExceptionUtilities.getRootCause(e).getMessage(), e);
|
Logger.getLogger("ui").log(Level.WARNING, ExceptionUtilities.getRootCauseMessage(e), e);
|
||||||
} finally {
|
} finally {
|
||||||
tab.setLoading(false);
|
tab.setLoading(false);
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,6 +14,7 @@ import javax.swing.Icon;
|
||||||
import javax.swing.SwingUtilities;
|
import javax.swing.SwingUtilities;
|
||||||
|
|
||||||
import net.sourceforge.filebot.ResourceManager;
|
import net.sourceforge.filebot.ResourceManager;
|
||||||
|
import net.sourceforge.tuned.ExceptionUtilities;
|
||||||
import net.sourceforge.tuned.ui.notification.MessageNotification;
|
import net.sourceforge.tuned.ui.notification.MessageNotification;
|
||||||
import net.sourceforge.tuned.ui.notification.NotificationManager;
|
import net.sourceforge.tuned.ui.notification.NotificationManager;
|
||||||
import net.sourceforge.tuned.ui.notification.QueueNotificationLayout;
|
import net.sourceforge.tuned.ui.notification.QueueNotificationLayout;
|
||||||
|
@ -61,7 +62,7 @@ public class NotificationLoggingHandler extends Handler {
|
||||||
|
|
||||||
if (message == null || message.isEmpty()) {
|
if (message == null || message.isEmpty()) {
|
||||||
// if message is empty, display exception string
|
// if message is empty, display exception string
|
||||||
message = record.getThrown().toString();
|
return ExceptionUtilities.getMessage(record.getThrown());
|
||||||
}
|
}
|
||||||
|
|
||||||
return message;
|
return message;
|
||||||
|
|
|
@ -18,6 +18,7 @@ import java.util.Iterator;
|
||||||
import java.util.LinkedHashSet;
|
import java.util.LinkedHashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
import javax.swing.AbstractAction;
|
import javax.swing.AbstractAction;
|
||||||
|
@ -31,6 +32,7 @@ import javax.swing.tree.TreePath;
|
||||||
import javax.swing.tree.TreeSelectionModel;
|
import javax.swing.tree.TreeSelectionModel;
|
||||||
|
|
||||||
import net.sourceforge.filebot.ResourceManager;
|
import net.sourceforge.filebot.ResourceManager;
|
||||||
|
import net.sourceforge.tuned.ExceptionUtilities;
|
||||||
import net.sourceforge.tuned.FilterIterator;
|
import net.sourceforge.tuned.FilterIterator;
|
||||||
import net.sourceforge.tuned.TreeIterator;
|
import net.sourceforge.tuned.TreeIterator;
|
||||||
|
|
||||||
|
@ -158,7 +160,7 @@ public class FileTree extends JTree {
|
||||||
Desktop.getDesktop().open(file);
|
Desktop.getDesktop().open(file);
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Logger.getLogger("ui").warning(e.getMessage());
|
Logger.getLogger("ui").log(Level.WARNING, ExceptionUtilities.getRootCauseMessage(e), e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,7 @@ package net.sourceforge.filebot.ui.panel.analyze;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
import net.sourceforge.filebot.ui.panel.analyze.FileTree.AbstractTreeNode;
|
import net.sourceforge.filebot.ui.panel.analyze.FileTree.AbstractTreeNode;
|
||||||
|
@ -50,7 +51,7 @@ class FileTreeTransferablePolicy extends BackgroundFileTransferablePolicy<Abstra
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void process(Exception e) {
|
protected void process(Exception e) {
|
||||||
Logger.getLogger("ui").warning(ExceptionUtilities.getRootCause(e).getMessage());
|
Logger.getLogger("ui").log(Level.WARNING, ExceptionUtilities.getRootCauseMessage(e), e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -90,11 +90,13 @@ abstract class Tool<M> extends JComponent {
|
||||||
try {
|
try {
|
||||||
setModel(get());
|
setModel(get());
|
||||||
} catch (Exception e) {
|
} 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
|
// if it happens, it is supposed to
|
||||||
} else {
|
} else {
|
||||||
// should not happen
|
// should not happen
|
||||||
Logger.getLogger("global").log(Level.WARNING, e.toString(), e);
|
Logger.getLogger("global").log(Level.WARNING, e.getMessage(), e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,6 +13,7 @@ import javax.swing.AbstractAction;
|
||||||
|
|
||||||
import net.sourceforge.filebot.ResourceManager;
|
import net.sourceforge.filebot.ResourceManager;
|
||||||
import net.sourceforge.filebot.similarity.Match;
|
import net.sourceforge.filebot.similarity.Match;
|
||||||
|
import net.sourceforge.tuned.ExceptionUtilities;
|
||||||
import net.sourceforge.tuned.FileUtilities;
|
import net.sourceforge.tuned.FileUtilities;
|
||||||
|
|
||||||
|
|
||||||
|
@ -68,7 +69,7 @@ class RenameAction extends AbstractAction {
|
||||||
Logger.getLogger("ui").info(String.format("%d files renamed.", renameCount));
|
Logger.getLogger("ui").info(String.format("%d files renamed.", renameCount));
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
// rename failed
|
// rename failed
|
||||||
Logger.getLogger("ui").warning(e.getMessage());
|
Logger.getLogger("ui").warning(ExceptionUtilities.getRootCauseMessage(e));
|
||||||
|
|
||||||
boolean revertFailed = false;
|
boolean revertFailed = false;
|
||||||
|
|
||||||
|
|
|
@ -10,6 +10,7 @@ import java.awt.event.ActionEvent;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
import javax.swing.AbstractAction;
|
import javax.swing.AbstractAction;
|
||||||
|
@ -214,7 +215,7 @@ public class RenamePanel extends FileBotPanel {
|
||||||
model.names().addAll(names);
|
model.names().addAll(names);
|
||||||
model.files().addAll(files);
|
model.files().addAll(files);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Logger.getLogger("ui").warning(ExceptionUtilities.getRootCause(e).getMessage());
|
Logger.getLogger("ui").log(Level.WARNING, ExceptionUtilities.getRootCauseMessage(e), e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -13,6 +13,8 @@ import javax.swing.border.EmptyBorder;
|
||||||
import javax.swing.table.DefaultTableCellRenderer;
|
import javax.swing.table.DefaultTableCellRenderer;
|
||||||
import javax.swing.table.TableCellRenderer;
|
import javax.swing.table.TableCellRenderer;
|
||||||
|
|
||||||
|
import net.sourceforge.tuned.ExceptionUtilities;
|
||||||
|
|
||||||
|
|
||||||
class ChecksumTableCellRenderer extends DefaultTableCellRenderer {
|
class ChecksumTableCellRenderer extends DefaultTableCellRenderer {
|
||||||
|
|
||||||
|
@ -34,7 +36,7 @@ class ChecksumTableCellRenderer extends DefaultTableCellRenderer {
|
||||||
setText("Pending ...");
|
setText("Pending ...");
|
||||||
break;
|
break;
|
||||||
case ERROR:
|
case ERROR:
|
||||||
setText(checksum.getError().getMessage());
|
setText(ExceptionUtilities.getMessage(checksum.getError()));
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
return progressBarRenderer.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
|
return progressBarRenderer.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
|
||||||
|
|
|
@ -55,7 +55,7 @@ class SfvTransferablePolicy extends BackgroundFileTransferablePolicy<ChecksumCel
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void process(Exception e) {
|
protected void process(Exception e) {
|
||||||
Logger.getLogger("ui").warning(ExceptionUtilities.getRootCause(e).getMessage());
|
Logger.getLogger("ui").log(Level.WARNING, ExceptionUtilities.getRootCauseMessage(e), e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -13,6 +13,22 @@ public final class ExceptionUtilities {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static String getRootCauseMessage(Throwable t) {
|
||||||
|
return getMessage(getRootCause(t));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static String getMessage(Throwable t) {
|
||||||
|
String message = t.getMessage();
|
||||||
|
|
||||||
|
if (message == null || message.isEmpty()) {
|
||||||
|
return t.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
return message;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public static RuntimeException asRuntimeException(Throwable t) {
|
public static RuntimeException asRuntimeException(Throwable t) {
|
||||||
if (t instanceof RuntimeException) {
|
if (t instanceof RuntimeException) {
|
||||||
return (RuntimeException) t;
|
return (RuntimeException) t;
|
||||||
|
|
Loading…
Reference in New Issue