Since error messages are rarely part of the exception API, testing for
them is fragile and prone to errors. For example, what if the message
changes to "no money" or "out of funds" or "insufficient funds" or
"keine Mittel"? Since the error message is not part of the API, that can
happen at any time, without warning.
The obvious way to do that is to create BeyondLimit and NoFunds
subclasses of DatabaseError. Why can't you do that?
That seems like a backwards way to do it to me. If you're the author of
the exception class, why not just subclass your exceptions the regular
way and get a real subclass?
As Stephen said, messages are intentionally not part of the defined API. [...]
"[...] The exception matching machinery ignores the __instancecheck__ mechanism."