This question covers a broad range of programming languages; however, I am specifically working with Python in this case.
I would like to create some user defined exceptions, but I'm not sure how fine-grained they should be. For example, if I have the following class:
class Race(object):
def __init__(self, start_time, end_time):
if end_time < start_time:
raise WhatToNameThisError
self._start_time = start_time
self._finish_time = end_time
I would like an exception to be raised if the finish time occurs before the start time, but I could I call it?
- RaceError (all exceptions related to the Race class can use this, and the message can distinguish between them)
- RaceFinishTimeBeforeStartTime (more specific, but means I know exactly what I'm catching)
I'm sure there are other ways of looking at this, and thus more options for naming an exception. Are there any standards or guidelines which outline this?