Error functions

The following group of functions defines the behavior of the library when errors occur during the execution.

Usage

The following examples, that can be found in the directory examples of the library sources, show the typical usage of this group of functions.

The example in C language is cerror.c.

The following example shows how to stop the execution on the error.

t_calcephbin * eph;

/* set the  error handler to stop on error */
calceph_seterrorhandler(2, 0);

/* open the ephemeris file */
eph = calceph_open("example1.dat");

/*... computation ... */

The following example shows how to define a custom error handler function.

/*-----------------------------------------------------------------*/
/* custom error handler */
/*-----------------------------------------------------------------*/
static void myhandler(const char *msg)
{
        puts("The calceph calls the function myhandler");
        printf("The message contains %d characters\n", (int)strlen(msg));
        puts("The error message is :");
        puts("----------------------");
        puts(msg);
        puts("----------------------");
        puts("The error handler returns");
}

int main(void)
{
    t_calcephbin * eph;

    /* set the  error handler to stop on error */
    calceph_seterrorhandler(3, myhandler);

    /* open the ephemeris file */
    eph = calceph_open("example1.dat");

    /*... computation ... */

    return 0;
}