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;
}