[Ecls-list] CL_CATCH_ALL_BEGIN?
Seth Burleigh
seth at tewebs.com
Tue Mar 23 22:24:46 UTC 2010
In a previous post, I didn't quite test all the possible cases. Now, the
following code will go into a debugger if something like (a:hi) is typed
into the command prompt. Error message:
Cannot find the external symbol HI in #<"A" package>.
No restarts available.
Broken at SI:BYTECODES. [Evaluation of: (READ-FROM-STRING "(a:hi)
")]
This time the error results from the c_string_to_object call. However,
shouldn't this be caught by the CL_CATH_ALL_BEGIN clause?
Also, is there any way to access the error object (and thus the error
message) from the CL_CATCH_ALL_BEGIN clause?
---------------
#include <ecl/ecl.h>
#include <stdio.h>
#include <string.h>
int main(int argc, char **argv) {
cl_boot(argc, argv);
cl_env_ptr env = ecl_process_env();
while (1) {
printf("\n>>");
int nbytes = 100;
char *str = (char*)malloc(nbytes);
nbytes = fgets(str, nbytes, stdin) - str;
if (strcmp(str,"exit\n")==0 ) {
break;
}
CL_CATCH_ALL_BEGIN(env) {
puts("BEFORE");
cl_object obj = c_string_to_object(str);
puts("AFTER");
cl_object evaled = cl_safe_eval(obj,Cnil,Cnil);
cl_pprint(1,evaled);
} CL_CATCH_ALL_IF_CAUGHT {
puts("ERROR");
} CL_CATCH_ALL_END;
free(str);
}
cl_shutdown();
}
More information about the ecl-devel
mailing list