1 // JRclient library - client interface to Rserve, see http://www.rosuda.org/Rserve/
2 // Copyright (C) 2004 Simon Urbanek
3 // --- for licensing information see LICENSE file in the original JRclient distribution ---
5 // RserveException.java
7 // Created by Simon Urbanek on Mon Aug 18 2003.
12 package org.rosuda.REngine.Rserve;
14 import org.rosuda.REngine.Rserve.protocol.RPacket;
15 import org.rosuda.REngine.Rserve.protocol.RTalk;
16 import org.rosuda.REngine.REngineException;
18 public class RserveException extends REngineException {
20 protected int reqReturnCode;
22 public String getRequestErrorDescription() {
23 return getRequestErrorDescription(reqReturnCode);
26 public String getRequestErrorDescription(int code) {
28 case 0: return "no error";
29 case 2: return "R parser: input incomplete";
30 case 3: return "R parser: syntax error";
31 case RTalk.ERR_auth_failed: return "authorization failed";
32 case RTalk.ERR_conn_broken: return "connection broken";
33 case RTalk.ERR_inv_cmd: return "invalid command";
34 case RTalk.ERR_inv_par: return "invalid parameter";
35 case RTalk.ERR_IOerror: return "I/O error on the server";
36 case RTalk.ERR_not_open: return "connection is not open";
37 case RTalk.ERR_access_denied: return "access denied (local to the server)";
38 case RTalk.ERR_unsupported_cmd: return "unsupported command";
39 case RTalk.ERR_unknown_cmd: return "unknown command";
40 case RTalk.ERR_data_overflow: return "data overflow, incoming data too big";
41 case RTalk.ERR_object_too_big: return "evaluation successful, but returned object is too big to transport";
42 case RTalk.ERR_out_of_mem: return "FATAL: Rserve ran out of memory, closing connection";
43 case RTalk.ERR_session_busy: return "session is busy";
44 case RTalk.ERR_detach_failed: return "session detach failed";
45 case RTalk.ERR_ctrl_closed: return "control pipe to master process is closed/broken";
47 return "error code: "+code;
50 public String getMessage() {
51 return super.getMessage()+((reqReturnCode!=-1)?", request status: "+getRequestErrorDescription():"");
54 public RserveException(RConnection c, String msg) {
58 public RserveException(RConnection c, String msg, int requestReturnCode) {
60 reqReturnCode=requestReturnCode;
61 if (c!=null) c.lastError=getMessage();
64 public RserveException(RConnection c, String msg, RPacket p) {
65 this(c, msg, (p==null)?-1:p.getStat());
68 public int getRequestReturnCode() {