Révision 3199

tmp/org.txm.statsengine.r.core/src/org/txm/statsengine/r/core/exceptions/RWorkspaceException.java (revision 3199)
29 29

  
30 30
import org.txm.statsengine.core.StatException;
31 31

  
32
// TODO: Auto-generated Javadoc
33 32
/**
34 33
 * Super-class of all exception related to the R engine.
35 34
 * 
......
45 44
	 */
46 45
	public RWorkspaceException() {
47 46
		super();
48
		// TODO Auto-generated constructor stub
49 47
	}
50 48

  
51 49
	/**
52 50
	 * Instantiates a new r workspace exception.
53 51
	 *
54
	 * @param arg0 the arg0
55
	 * @param arg1 the arg1
52
	 * @param message the message
53
	 * @param cause the cause
56 54
	 */
57
	public RWorkspaceException(String arg0, Throwable arg1) {
58
		super(arg0, arg1);
59
		// TODO Auto-generated constructor stub
55
	public RWorkspaceException(String message, Throwable cause) {
56
		super(message, cause);
60 57
	}
61 58

  
62 59
	/**
63 60
	 * Instantiates a new r workspace exception.
64 61
	 *
65
	 * @param arg0 the arg0
62
	 * @param message the message
66 63
	 */
67
	public RWorkspaceException(String arg0) {
68
		super(arg0);
69
		// TODO Auto-generated constructor stub
64
	public RWorkspaceException(String message) {
65
		super(message);
70 66
	}
71 67

  
72 68
	/**
73 69
	 * Instantiates a new r workspace exception.
74 70
	 *
75
	 * @param arg0 the arg0
71
	 * @param cause the cause
76 72
	 */
77
	public RWorkspaceException(Throwable arg0) {
78
		super(arg0);
79
		// TODO Auto-generated constructor stub
73
	public RWorkspaceException(Throwable cause) {
74
		super(cause);
80 75
	}
76
	
77
	public String getMessage() {
78
		return "R error: "+super.getMessage();
79
	}
81 80

  
82 81
}
tmp/org.txm.statsengine.r.core/src/org/txm/statsengine/r/core/RScriptEngine.java (revision 3199)
13 13
import org.txm.core.messages.TXMCoreMessages;
14 14
import org.txm.statsengine.r.core.exceptions.RWorkspaceException;
15 15
import org.txm.statsengine.r.core.messages.RCoreMessages;
16
import org.txm.utils.io.IOUtils;
16 17
import org.txm.utils.logger.Log;
17 18

  
18 19
public class RScriptEngine extends ScriptEngine {
......
109 110
			//execute a file line per line
110 111

  
111 112
			//if (TxmPreferences.getBoolean(RPreferencePage.R_REMOTE)) {
112
				BufferedReader reader = new BufferedReader(new FileReader(rFile));// create a file reader
113
				String line = reader.readLine();// read next line
114
				StringBuffer buffer = new StringBuffer();
115
				while (line != null) {
116
					buffer.append(line+"\n"); //$NON-NLS-1$
117
					line = reader.readLine();//read next line
118
				}
113

  
119 114
				
120
				String allScript = buffer.toString();
121 115
				//if (rw.isLogging() && allScript.length() > 0) RConsole.printUser(allScript);
122 116

  
123 117
				//String str = rw.userEval(allScript); // evaluate line in R
118
				String allScript = IOUtils.getText(rFile);
124 119
				rw.eval(allScript);
125 120
				//if (str != null && rw.isLogging() && str.length() > 0)
126 121
					//RConsole.printServer(str);
127
				reader.close();
128 122
//			} else {
129 123
//				String cmd = "source(\""+rFile.getAbsolutePath().replace("\\", "/")+"\")";
130 124
//				if (rw.isLogging())
......
137 131
			System.out.println(TXMCoreMessages.bind(RCoreMessages.doneColon, (System.currentTimeMillis()-time)));
138 132
			
139 133
		} catch(Exception e) {
140
			System.out.println(NLS.bind(RCoreMessages.errorWhileRunningRScriptP0ColonP1, rFile, e)); 
141
			//StatusLine.error(NLS.bind(RCoreMessages.errorWhileRunningRScriptP0ColonP1, rFile, e)); 
134
			System.out.println(NLS.bind(RCoreMessages.errorWhileRunningRScriptP0ColonP1, rFile, e.getMessage())); 
142 135
			Log.printStackTrace(e);
143 136
			return Status.CANCEL_STATUS;
144 137
		} finally {
tmp/org.txm.statsengine.r.core/src/org/txm/statsengine/r/core/RWorkspace.java (revision 3199)
1143 1143
		}
1144 1144
		catch (RserveException e) {
1145 1145
			RWorkspace.printLastSafeEvalExpr();
1146
			throw new RWorkspaceException(e);
1146
			throw new RWorkspaceException(e.getMessage()+ "; " +exp.trim(), e);
1147 1147
		}
1148 1148
		catch (Exception e) {
1149
			throw new RException(exp + "; " + e.getMessage(), e); //$NON-NLS-1$
1149
			throw new RException(e.getMessage()+ "; " +exp.trim(), e); //$NON-NLS-1$
1150 1150
		}
1151 1151
		
1152 1152
		return res;
......
1560 1560
			}
1561 1561
		}
1562 1562
		catch (Exception e) {
1563
			// TODO Auto-generated catch block
1564
			e.printStackTrace();
1563
//			Log.warning(NLS.bind("** {0}", e.getMessage()));
1564
//			Log.printStackTrace(e);
1565
			throw e;//new RException(expr, e.getMessage());
1565 1566
		}
1566 1567
		finally {
1567 1568
			if (r != null && r.inherits("try-error")) {

Formats disponibles : Unified diff