diff --git a/conservancy_beancount/errors.py b/conservancy_beancount/errors.py index 7f331a49bfd5831759ed682009c185d58cd72e18..6d4611bbd9b1ad9cb4725b98acaf7a0cede9659f 100644 --- a/conservancy_beancount/errors.py +++ b/conservancy_beancount/errors.py @@ -65,3 +65,16 @@ class InvalidMetadataError(Error): txn, source, ) + + +class InvalidEntityError(InvalidMetadataError): + def __init__(self, txn, post=None, key='entity', value=None, source=None): + if post is None: + srcname = 'transaction' + else: + srcname = post.account + if value is None: + msg = "{} missing entity".format(srcname) + else: + msg = "{} entity malformed: {}".format(srcname, value) + super(InvalidMetadataError, self).__init__(msg, txn, source)