There are many errors that should be recoverable but galsim throws a generic
error. This is a problem because it may not be clear from where this error
originates. One cannot distinguish the recoverable from non-recoverable
errors.
For example, a pipeline may run many calls to galsim methods; tens is not
unusual. Each of these may throw a RuntimeError or ValueError. The
pipeline, and galsim itself, will intersperse other python function calls with
galsim calls, many of which may throw the same errors.
The difference is that most RuntimeError or ValueError thrown by the python
standard library are not recoverable, they signify a bug in the program, and
the program should crash and the user should fix the code.
But many times when galsim throws such an error it is not a bug, galsim simply
does not know what to do with the inputs or has some internal numerical
restrictions that are not met. Often one can just re-call the method with
modified parameters, or otherwise deal with this an move on. If I knew the
exception was a galsim exception I could write some robust code to deal with
the situation.
An example came up today when the fft code threw a RuntimeError because the
sheared image would require too large an FFT. This is not a bug, I can deal
with this quite cleanly at run time, but I can't tell if this RuntimeError
is coming from galsim or not.
I propose replacing some uses of RuntimeError or ValueError with something
like GalsimValueError, GalsimRangeError or whatever, inheriting from a base
GalsimError class. These can then be caught and dealt with robustly.
There are many errors that should be recoverable but galsim throws a generic
error. This is a problem because it may not be clear from where this error
originates. One cannot distinguish the recoverable from non-recoverable
errors.
For example, a pipeline may run many calls to galsim methods; tens is not
unusual. Each of these may throw a
RuntimeErrororValueError. Thepipeline, and galsim itself, will intersperse other python function calls with
galsim calls, many of which may throw the same errors.
The difference is that most
RuntimeErrororValueErrorthrown by the pythonstandard library are not recoverable, they signify a bug in the program, and
the program should crash and the user should fix the code.
But many times when galsim throws such an error it is not a bug, galsim simply
does not know what to do with the inputs or has some internal numerical
restrictions that are not met. Often one can just re-call the method with
modified parameters, or otherwise deal with this an move on. If I knew the
exception was a galsim exception I could write some robust code to deal with
the situation.
An example came up today when the fft code threw a
RuntimeErrorbecause thesheared image would require too large an FFT. This is not a bug, I can deal
with this quite cleanly at run time, but I can't tell if this
RuntimeErroris coming from galsim or not.
I propose replacing some uses of
RuntimeErrororValueErrorwith somethinglike
GalsimValueError,GalsimRangeErroror whatever, inheriting from a baseGalsimErrorclass. These can then be caught and dealt with robustly.