Skip to content

basic error message from rniEval #59

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions jri/src/Rengine.c
Original file line number Diff line number Diff line change
@@ -121,6 +121,12 @@ JNIEXPORT jlong JNICALL Java_org_rosuda_JRI_Rengine_rniParse
return SEXP2L(pstr);
}

void throw_jri_eval_error(JNIEnv *env)
{
jclass exception = (*env)->FindClass(env, "java/lang/RuntimeException");
(*env)->ThrowNew(env, exception, R_curErrorBuf());
}

/**
* Evaluates one expression or a list of expressions
*
@@ -138,7 +144,7 @@ JNIEXPORT jlong JNICALL Java_org_rosuda_JRI_Rengine_rniEval
int i = 0, l;

/* invalid (NULL) expression (parse error, ... ) */
if (!exp) return 0;
if (!exp) throw_jri_eval_error(env);

if (TYPEOF(exps) == EXPRSXP) {
/* if the object is a list of exps, eval them one by one */
@@ -147,14 +153,13 @@ JNIEXPORT jlong JNICALL Java_org_rosuda_JRI_Rengine_rniEval
es = R_tryEval(VECTOR_ELT(exps,i), eval_env, &er);

/* an error occured, no need to continue */
if (er) return 0;
if (er) throw_jri_eval_error(env);
i++;
}
} else
es = R_tryEval(exps, eval_env, &er);

/* er is just a flag - on error return 0 */
if (er) return 0;
if (er) throw_jri_eval_error(env);

return SEXP2L(es);
}