Python: is RuntimeError acceptable for general use?

This is… OK. Ideally, you would have separate exceptions for each reasonably distinct situation (e.g. one exception for all “the config file is malformed” errors, reuse FileNotFoundError in 3.x for “the config file doesn’t exist”, etc.). But this is one of the more innocuous forms of technical debt.

The downside is that if you ever do introduce those separate exceptions, they may need to subclass from RuntimeError for reasons of backwards compatibility. That’s kind of ugly, but mostly harmless.

Leave a Comment