This question covers a wide range of programming languages; however, I specifically work with Python in this case.
I would like to create some custom exceptions, but I'm not sure how fine 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 end time is before the start, but could I name 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 caught)
I am sure there are other ways to look at this, and therefore more options to indicate an exception. Are there any standards or guidelines that describe this?
Jon source share