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 Python language is pyerror.py.

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")