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

from calcephpy import *

#set the  error handler to stop on error
seterrorhandler(2, 0);

# open the ephemeris file
peph = CalcephBin.open("example1.dat")

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

from calcephpy import *

#-----------------------------------------------------------------
# custom error handler
#-----------------------------------------------------------------
def myhandler(msg):
    print("The calceph calls the function myhandler");
    print("The message contains {0} characters\n".format(len(msg)))
    print("The error message is :")
    print("----------------------")
    print(msg)
    print("----------------------")
    print("The error handler returns")

# set the  error handler to use my own callback
seterrorhandler(3, myhandler)

# open the ephemeris file
peph = CalcephBin.open("example1.dat")