Domanda

Task: Embed ECL lisp in my project, setup error handling and detailed error reporting (where occurred, kind of error, etc.)

I tried to do that such way:

cl_def_c_function_va(
    c_string_to_object("SYSTEM:UNIVERSAL-ERROR-HANDLER"),
    LispErrorHandler);

ECL have no documentation on its embedded API and no documentation on error handling...

Can you suggest how to implement that?

È stato utile?

Soluzione

There is no global error handler because this is not the Common Lisp philosophy. If you want to handle errors, do it the lisp way.

1) Create a function that uses HANDLER-CASE or HANDLER-BIND to set up the appropriate error handlers and catch errors around a form that is to be evaluated. Something like

(DEFUN MY-EVAL (FORM) (HANDLER-CASE (EVAL FORM) (ERROR (C) ...) (MY-ERROR (C) ...) ...))

This function may be defined in your C code and invoked.

2) Use the functions that ECL creates that catch all errors. The most important one is si_safe_eval(form, environment, error_value). It evaluates the lisp FORM in an ENVIRONMENT (Typically Cnil) and returns its output or ERROR_VALUE if it got some error.

Some examples that use one or the other technique: http://thread.gmane.org/gmane.lisp.ecl.general/5365 (2nd message) http://thread.gmane.org/gmane.lisp.ecl.general/8526/focus=8529

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top