Mar-16-2017, 07:09 AM
i am (re-)writing a complex function with many variations of bad ways to call it. in cases where a bad type is given i raise a TypeError. for values out of range or just wrong i raise a ValueError. what should i raise for other bad cases? i am doing more raising exceptions unless there is a programmatic reason for the caller to simply handle the unusual case, such as providing None to indicate no more of something (the function may need to turn out the lights).