errors: Add a __repr__.

This makes the errors easier to understand in test failures.
This commit is contained in:
Brett Smith 2020-03-05 13:57:20 -05:00
parent 34090df23f
commit 910b95c942

View file

@ -20,6 +20,13 @@ class _BaseError(Exception):
self.entry = entry self.entry = entry
self.source = entry.meta if source is None else source self.source = entry.meta if source is None else source
def __repr__(self):
return "{clsname}<{source[filename]}:{source[lineno]}: {message}>".format(
clsname=type(self).__name__,
message=self.message,
source=self.source,
)
class InvalidMetadataError(_BaseError): class InvalidMetadataError(_BaseError):
def __init__(self, txn, post, key, value=None, source=None): def __init__(self, txn, post, key, value=None, source=None):