A simple thing that would help a little would be to evaluate the function immediately after making it.  Something like:
```
tp = eval('lambda wave : ' + tp)
# Just evaluate the function somewhere to make sure it is valid before continuing on.
if red_limit is not None:
    tp(red_limit)
elif blue_limit is not None:
    tp(blue_limit)
else:
    tp(700)
```
It would at least give an error message that indicates that `foo` (in this case) was wrongly being interpreted as a function to be evaluated rather than a file name, which would probably help the user track down the error.

There are a number of other places in GalSim where we construct lambda functions from user input (e.g. PowerSpectrum, UVFunction, etc.).  Probably ought to do something similar in those places as well.