C Function: Error

Npt documentation.

Reference: ANSI Common Lisp npt

Function Specification

The following function specifications are described in lisp.h.

void lisp_abort(void);
void lisp_abortf(const char *fmt, ...);
void lisp_abort8(const void *fmt, ...);
void lisp_abort16(const void *fmt, ...);
void lisp_abort32(const void *fmt, ...);
lisp_abort_calltype lisp_set_abort_handler(lisp_abort_calltype call);
lisp_abort_calltype lisp_set_abort_setjmp_handler(void);
Lisp_abort_Begin
Lisp_abort_End
Lisp_abort_throw
int lisp_signal_(addr condition);
int lisp_error_(addr condition);
int lisp_error8_(const void *str, ...);
int lisp_error16_(const void *str, ...);
int lisp_error32_(const void *str, ...);
int lisp_warn8_(const void *str, ...);
int lisp_warn16_(const void *str, ...);
int lisp_warn32_(const void *str, ...);

1. abort

Functions of the LISP ABORT.

void lisp_abort(void);
void lisp_abortf(const char *fmt, ...);
void lisp_abort8(const void *fmt, ...);
void lisp_abort16(const void *fmt, ...);
void lisp_abort32(const void *fmt, ...);
lisp_abort_calltype lisp_set_abort_handler(lisp_abort_calltype call);
lisp_abort_calltype lisp_set_abort_setjmp_handler(void);
Lisp_abort_Begin
Lisp_abort_End
Lisp_abort_throw

Function lisp_abort

void lisp_abort(void);

Executes LISP ABORT.
When LISP ABORT is executed, the following behavior is performed.

Function lisp_abortf

void lisp_abortf(const char *fmt, ...);

Input: fmt, `printf` format.

Print a message to standard error and then LISP ABORT.
No Lisp is used, so it can be run at any time.

Function lisp_abort8

void lisp_abort8(const void *fmt, ...);
void lisp_abort16(const void *fmt, ...);
void lisp_abort32(const void *fmt, ...);

Input: fmt, unicode string.

Output error messages to error-output using the lisp_format_ function,and then LISP ABORT.
Since the process is executed via Lisp, Common Lisp must be executable.
See the lisp_string8_ function for details on Unicode strings.

Function lisp_abort16

See lisp_abort8.

Function lisp_abort32

See lisp_abort8.

Function lisp_set_abort_handler

lisp_abort_calltype lisp_set_abort_handler(lisp_abort_calltype call);

Input: call, handler, void (*)(void).
Return: Handler before configuration.

Specifies a handler to be called when LISP ABORT is executed.
If the argument is NULL, the handler will be removed.

Function lisp_set_abort_setjmp_handler

lisp_abort_calltype lisp_set_abort_setjmp_handler(void);

Return: Handler before configuration.

Set the handler for setjmp.

Macro Lisp_abort_Begin

#define Lisp_abort_Begin ...
#define Lisp_abort_End ...
#define Lisp_abort_throw() ...

Capture LISP ABORT.
To use this mechanism, you need to run lisp_set_abort_setjmp_handler to set the setjmp handler.

Use Lisp_abort_Begin and Lisp_abort_End for capturing.
Examples are shown below.

Lisp_abort_Begin {
    /* code */
}
Lisp_abort_End;

If Lisp_abort_throw() is executed, the control jumps to Lisp_abort_End by longjmp.

The handler registered by lisp_set_abort_setjmp_handler is simply a code that Lisp_abort_throw() will be executed, for example, the following function.

void abort_setjmp_handler(void)
{
    Lisp_abort_throw();
}

Normally, macros are expanded to setjmp/longjmp, but if you have a C++ compiler and LISP_ABORT_SETJMP is not defined, macros are expanded to try/catch.

A typical usage example is shown below.

int main(void)
{
    int finish;
    lisp_abort_calltype handler;

    handler = lisp_set_abort_setjmp_handler();
    finish = 0;
    Lisp_abort_Begin {
        lisp_abort();
        finish = 1;
    }
    Lisp_abort_End;
    lisp_set_abort_handler(handler);

    if (finish == 0)
        printf("LISP ABORT\n");

    return 0;
}

Macro Lisp_abort_End

See Lisp_abort_Begin.

Macro Lisp_abort_throw

See Lisp_abort_Begin.

2. signal

Function to generate a condition.

int lisp_signal_(addr condition);
int lisp_error_(addr condition);

Escape Function lisp_signal_

int lisp_signal_(addr condition);

Input: condition, instance.
Return: Non-zero when escaping.

Passes the condition argument to signal.
It is the same as signal in Common Lisp.
If condition is a hold variable, its contents will be used.

Escape Function lisp_error_

int lisp_error_(addr condition);

Input: condition, instance.
Return: Non-zero.

Passes the condition argument to error.
It is the same as error in Common Lisp.
If condition is a hold variable, its contents will be used.

3. error

Functions of the error.

int lisp_error8_(const void *str, ...);
int lisp_error16_(const void *str, ...);
int lisp_error32_(const void *str, ...);

Escape Function lisp_error8_

int lisp_error8_(const void *str, ...);
int lisp_error16_(const void *str, ...);
int lisp_error32_(const void *str, ...);

Input: str, unicode string.
Return: Non-zero.

Run the simple-error condition.
It is the same as error in Common Lisp.
See the lisp_string8_ function for details on Unicode strings.

Escape Function lisp_error16_

See lisp_error8_.

Escape Function lisp_error32_

See lisp_error8_.

4. warn

Functions of the warn.

int lisp_warn8_(const void *str, ...);
int lisp_warn16_(const void *str, ...);
int lisp_warn32_(const void *str, ...);

Escape Function lisp_warn8_

int lisp_warn8_(const void *str, ...);
int lisp_warn16_(const void *str, ...);
int lisp_warn32_(const void *str, ...);

Input: str, unicode string.
Return: Non-zero when escaping.

Run the simple-warning condition.
It is the same as warn in Common Lisp.
See the lisp_string8_ function for details on Unicode strings.

Escape Function lisp_warn16_

See lisp_warn8_.

Escape Function lisp_warn32_

See lisp_warn8_.