[Python-ideas] Consistent programming error handling idiom
rosuav at gmail.com
Sat Apr 9 01:32:12 EDT 2016
On Sat, Apr 9, 2016 at 7:25 AM, Rian Hunter <rian at thelig.ht> wrote:
> I want a consistent opt-in idiom with community consensus. I want a clear
> way to express that an exception is an error and not an internal bug. It
> doesn't have to catch 100% of cases, the idiom just needs to approach
> consistency across all Python libraries that I may import.
> If the programmer doesn't pay attention to the idiom, then is_a_bug() will
> never return true (or not True if it's is_not_a_bug()). AssertionError is
> already unambiguous, I'm sure there are other candidates as well.
> I'm not the first or only one to want something like this
The problem with posts like that is that it assumes there's some kind
of defined category of "stuff you always want to catch" vs "stuff you
never want to catch". This simply isn't the case. You ONLY catch the
exceptions you truly understand. Everything else, you leave. There's
seldom a need to catch a broad-but-specific subset of exceptions, and
those needs aren't entirely consistent, so they fundamentally cannot
be codified into the hierarchy.
More information about the Python-ideas