|
From: <pat...@us...> - 2010-08-18 20:38:57
|
Revision: 1124
http://cishell.svn.sourceforge.net/cishell/?rev=1124&view=rev
Author: pataphil
Date: 2010-08-18 20:38:51 +0000 (Wed, 18 Aug 2010)
Log Message:
-----------
* Added handling for AlgorithmCanceledException, so Algorithms can (optionally) cancel out without the user seeing an awful error message box.
* Reviewed by Micah.
Modified Paths:
--------------
trunk/clients/gui/org.cishell.reference.gui.menumanager/src/org/cishell/reference/gui/menumanager/menu/AlgorithmWrapper.java
Modified: trunk/clients/gui/org.cishell.reference.gui.menumanager/src/org/cishell/reference/gui/menumanager/menu/AlgorithmWrapper.java
===================================================================
--- trunk/clients/gui/org.cishell.reference.gui.menumanager/src/org/cishell/reference/gui/menumanager/menu/AlgorithmWrapper.java 2010-08-12 16:14:56 UTC (rev 1123)
+++ trunk/clients/gui/org.cishell.reference.gui.menumanager/src/org/cishell/reference/gui/menumanager/menu/AlgorithmWrapper.java 2010-08-18 20:38:51 UTC (rev 1124)
@@ -25,6 +25,7 @@
import org.cishell.app.service.datamanager.DataManagerService;
import org.cishell.framework.CIShellContext;
import org.cishell.framework.algorithm.Algorithm;
+import org.cishell.framework.algorithm.AlgorithmCanceledException;
import org.cishell.framework.algorithm.AlgorithmExecutionException;
import org.cishell.framework.algorithm.AlgorithmFactory;
import org.cishell.framework.algorithm.AlgorithmProperty;
@@ -236,19 +237,30 @@
protected Data[] tryExecutingAlgorithm(Algorithm algorithm) {
Data[] outData = null;
+ final String algorithmName =
+ (String) serviceReference.getProperty(AlgorithmProperty.LABEL);
+
try {
outData = algorithm.execute();
+ } catch (AlgorithmCanceledException e) {
+ String logMessage = String.format(
+ "The algorithm: \"%s\" was canceled by the user. (Reason: %s)",
+ algorithmName,
+ e.getMessage());
+ log(LogService.LOG_WARNING, logMessage, e);
} catch (AlgorithmExecutionException e) {
- log(LogService.LOG_ERROR, "The Algorithm: \""
- + serviceReference.getProperty(AlgorithmProperty.LABEL)
- + "\" had an error while executing: " + e.getMessage(), e);
+ String logMessage = String.format(
+ "The algorithm: \"%s\" had an error while executing: %s",
+ algorithmName,
+ e.getMessage());
+ log(LogService.LOG_ERROR, logMessage, e);
} catch (RuntimeException e) {
- GUIBuilderService builder = (GUIBuilderService)
- ciShellContext.getService(GUIBuilderService.class.getName());
-
- builder.showError("Error!",
- "An unexpected exception occurred while " + "executing \""
- + serviceReference.getProperty(AlgorithmProperty.LABEL) + ".\"", e);
+ GUIBuilderService builder =
+ (GUIBuilderService) ciShellContext.getService(GUIBuilderService.class.getName());
+ String errorMessage = String.format(
+ "An unxpected error occurred while executing the algorithm \"%s\".",
+ algorithmName);
+ builder.showError("Error!", errorMessage, e);
}
return outData;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|