[Remoterengine-commits] r179 - pkg/RemoteREngine/inst/java_src/src/client/org/rosuda/REngine/remote/client
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Wed Sep 23 07:58:34 CEST 2009
Author: ian_long
Date: 2009-09-23 07:58:34 +0200 (Wed, 23 Sep 2009)
New Revision: 179
Added:
pkg/RemoteREngine/inst/java_src/src/client/org/rosuda/REngine/remote/client/REngineConnectException.java
pkg/RemoteREngine/inst/java_src/src/client/org/rosuda/REngine/remote/client/REngineEvaluationException.java
Modified:
pkg/RemoteREngine/inst/java_src/src/client/org/rosuda/REngine/remote/client/RemoteREngine.java
Log:
Updated exception handling to assist with automatic error handling within a server environment
Added: pkg/RemoteREngine/inst/java_src/src/client/org/rosuda/REngine/remote/client/REngineConnectException.java
===================================================================
--- pkg/RemoteREngine/inst/java_src/src/client/org/rosuda/REngine/remote/client/REngineConnectException.java (rev 0)
+++ pkg/RemoteREngine/inst/java_src/src/client/org/rosuda/REngine/remote/client/REngineConnectException.java 2009-09-23 05:58:34 UTC (rev 179)
@@ -0,0 +1,47 @@
+/*
+ * project : RemoteREngine
+ * package : org.rosuda.REngine.remote.client
+ * created : 22 Sep 2009
+ */
+package org.rosuda.REngine.remote.client;
+
+/**
+ * The R engine connect exception.
+ *
+ */
+public class REngineConnectException extends RuntimeException {
+
+ /**
+ * serialVersionUID : <code>long</code>
+ */
+ private static final long serialVersionUID = -6815651756285432282L;
+
+ /**
+ *
+ */
+ public REngineConnectException() {
+ super("Error in connecting to R server : ");
+ }
+
+ /**
+ * @param message
+ * @param cause
+ */
+ public REngineConnectException(String message, Throwable cause) {
+ super("Error connecting to R server : " + message, cause);
+ }
+
+ /**
+ * @param message
+ */
+ public REngineConnectException(String message) {
+ super("Error connecting to R server : " + message);
+ }
+
+ /**
+ * @param cause
+ */
+ public REngineConnectException(Throwable cause) {
+ super("Error connecting to R server ", cause);
+ }
+}
Property changes on: pkg/RemoteREngine/inst/java_src/src/client/org/rosuda/REngine/remote/client/REngineConnectException.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Date Revision Author HeadURL Id
Added: pkg/RemoteREngine/inst/java_src/src/client/org/rosuda/REngine/remote/client/REngineEvaluationException.java
===================================================================
--- pkg/RemoteREngine/inst/java_src/src/client/org/rosuda/REngine/remote/client/REngineEvaluationException.java (rev 0)
+++ pkg/RemoteREngine/inst/java_src/src/client/org/rosuda/REngine/remote/client/REngineEvaluationException.java 2009-09-23 05:58:34 UTC (rev 179)
@@ -0,0 +1,76 @@
+/*
+ * project : RemoteREngine
+ * package : org.rosuda.REngine.remote.client
+ * created : 22 Sep 2009
+ */
+package org.rosuda.REngine.remote.client;
+
+import org.rosuda.REngine.REXP;
+
+
+/**
+ * The R Engine Evaluation Runtime Exception.
+ * Class contains the REXP returned from the expression to support debugging
+ */
+public class REngineEvaluationException extends RuntimeException {
+
+ /**
+ * serialVersionUID : <code>long</code>
+ */
+ private static final long serialVersionUID = 1468472935008087370L;
+
+ /**
+ * Environment used in R to run the expression
+ * exp : <code>REXP</code>
+ */
+ private REXP exp;
+
+ /**
+ * Capture the environment in Remote R that was used to run the expression
+ */
+ public REngineEvaluationException(REXP exp) {
+ super();
+ this.exp = exp;
+ }
+
+ /**
+ * Throw an Exception due to an error in the connection on the Remote R
+ * @param exp Environment the expression was run in
+ * @param message Information about the exception
+ * @param cause Underlying cause of the exception
+ */
+ public REngineEvaluationException(REXP exp, String message, Throwable cause) {
+ super(message, cause);
+ this.exp = exp;
+ }
+
+ /**
+ * Record exception message and the environment from Remote R
+ * @param exp Environment the expression was to be run in
+ * @param message Message regarding the error
+ */
+ public REngineEvaluationException(REXP exp, String message) {
+ super(message);
+ this.exp = exp;
+ }
+
+ /**
+ * Throw an exception, recording the underlying cause
+ * @param exp Environment the expression was to be run in
+ * @param cause Underlying cause of the exception
+ */
+ public REngineEvaluationException(REXP exp, Throwable cause) {
+ super(cause);
+ this.exp = exp;
+ }
+
+ /**
+ * return the expression evaluated.
+ * @return Environment the expression was to be run in
+ */
+ public REXP getExp(){
+ return exp;
+ }
+
+
+}
Property changes on: pkg/RemoteREngine/inst/java_src/src/client/org/rosuda/REngine/remote/client/REngineEvaluationException.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Date Revision Author HeadURL Id
Modified: pkg/RemoteREngine/inst/java_src/src/client/org/rosuda/REngine/remote/client/RemoteREngine.java
===================================================================
--- pkg/RemoteREngine/inst/java_src/src/client/org/rosuda/REngine/remote/client/RemoteREngine.java 2009-09-22 11:47:58 UTC (rev 178)
+++ pkg/RemoteREngine/inst/java_src/src/client/org/rosuda/REngine/remote/client/RemoteREngine.java 2009-09-23 05:58:34 UTC (rev 179)
@@ -25,7 +25,6 @@
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
-import java.rmi.NotBoundException;
import java.rmi.RemoteException;
import java.rmi.registry.LocateRegistry;
import java.rmi.registry.Registry;
@@ -113,9 +112,8 @@
* @param registryHost Name or IP Address of the host containing the RMI registry
* @param name Name of the Remote server registered within the Registry
* @param port port to use to connect to the server
- * @throws EngineNotAvailableException Failed to connect to remote R engine
*/
- public RemoteREngine(String name, String registryHost, int port) throws EngineNotAvailableException {
+ public RemoteREngine(String name, String registryHost, int port){
if (name == null || name.length()==0) {
System.err.println("RMI Name of remote engine not defined");
}
@@ -142,11 +140,8 @@
callbackDispatcher.start();
valid = testConnection();
- } catch ( NotBoundException nb) {
- throw new EngineNotAvailableException("Unable to locate " + name + " within RMI Registry on " +
- registryHost,nb);
- } catch( Exception e ){
- throw new EngineNotAvailableException("Unable to create RemoteREngine",e);
+ } catch (Throwable e){
+ new REngineConnectException("Unable to connect to R server "+registryHost+":"+port+"/"+name, e);
}
shutdownHook = new RemoteREngineShutdownHook();
@@ -188,9 +183,8 @@
* @see RemoteREngineConstants#RMIPORT for the default value
* @param name name of the remote object in the registry
* @param registryHost host name
- * @throws EngineNotAvailableException Failed to connect to remote R engine
*/
- public RemoteREngine(String name, String registryHost ) throws EngineNotAvailableException {
+ public RemoteREngine(String name, String registryHost ){
this( name, registryHost, RemoteREngineConstants.RMIPORT ) ;
}
@@ -352,7 +346,7 @@
try{
res = engine.parseAndEval( text, where, resolve ) ;
} catch( RemoteException e){
- RemoteExceptionManager.send( e, "parseAndEval" );
+ throw new REngineEvaluationException(where, "Error in evaluate expression '" + text + "', cause "+e.getMessage(), e);
}
return res ;
}
@@ -553,4 +547,3 @@
}
}
}
-
More information about the Remoterengine-commits
mailing list