Bubble dialogs for exception firewall (common with Python modules), better Python load error

This commit is contained in:
Brian Carrier 2015-05-25 15:10:51 -04:00
parent 91648425fb
commit 404ea583b0
4 changed files with 20 additions and 2 deletions

View File

@ -24,6 +24,7 @@ import java.util.List;
import java.util.logging.Level;
import org.openide.util.NbBundle;
import org.sleuthkit.autopsy.coreutils.Logger;
import org.sleuthkit.autopsy.coreutils.MessageNotifyUtil;
import org.sleuthkit.datamodel.Content;
/**
@ -110,6 +111,11 @@ final class DataSourceIngestPipeline {
logger.log(Level.INFO, "{0} analysis of {1} (jobId={2}) finished", new Object[]{module.getDisplayName(), this.job.getDataSource().getName(), this.job.getDataSource().getId()});
} catch (Throwable ex) { // Catch-all exception firewall
errors.add(new IngestModuleError(module.getDisplayName(), ex));
String msg = ex.getMessage();
// Jython run-time errors don't seem to have a message, but have details in toString.
if (msg == null)
msg = ex.toString();
MessageNotifyUtil.Notify.error(module.getDisplayName() + " Error", msg);
}
if (this.job.isCancelled()) {
break;

View File

@ -21,6 +21,7 @@ package org.sleuthkit.autopsy.ingest;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import org.sleuthkit.autopsy.coreutils.MessageNotifyUtil;
import org.sleuthkit.datamodel.AbstractFile;
/**
@ -119,6 +120,11 @@ final class FileIngestPipeline {
module.process(file);
} catch (Throwable ex) { // Catch-all exception firewall
errors.add(new IngestModuleError(module.getDisplayName(), ex));
String msg = ex.getMessage();
// Jython run-time errors don't seem to have a message, but have details in toString.
if (msg == null)
msg = ex.toString();
MessageNotifyUtil.Notify.error(module.getDisplayName() + " Error", msg);
}
if (this.job.isCancelled()) {
break;
@ -144,6 +150,11 @@ final class FileIngestPipeline {
module.shutDown();
} catch (Throwable ex) { // Catch-all exception firewall
errors.add(new IngestModuleError(module.getDisplayName(), ex));
String msg = ex.getMessage();
// Jython run-time errors don't seem to have a message, but have details in toString.
if (msg == null)
msg = ex.toString();
MessageNotifyUtil.Notify.error(module.getDisplayName() + " Error", msg);
}
}
this.running = false;

View File

@ -1,2 +1,2 @@
JythonModuleLoader.errorMessages.failedToOpenModule=Failed to open {0}. See log for details.
JythonModuleLoader.errorMessages.failedToLoadModule=Failed to load {0} from {1}. See log for details.
JythonModuleLoader.errorMessages.failedToLoadModule=Failed to load {0}. {1}. See log for details.

View File

@ -81,8 +81,9 @@ public final class JythonModuleLoader {
objects.add( createObjectFromScript(script, className, interfaceClass));
} catch (Exception ex) {
logger.log(Level.SEVERE, String.format("Failed to load %s from %s", className, script.getAbsolutePath()), ex); //NON-NLS
// NOTE: using ex.toString() because the current version is always returning null for ex.getMessage().
DialogDisplayer.getDefault().notify(new NotifyDescriptor.Message(
NbBundle.getMessage(JythonModuleLoader.class, "JythonModuleLoader.errorMessages.failedToLoadModule", className, script.getAbsolutePath()),
NbBundle.getMessage(JythonModuleLoader.class, "JythonModuleLoader.errorMessages.failedToLoadModule", className, ex.toString()),
NotifyDescriptor.ERROR_MESSAGE));
}
}