From 910b95c9425e2b7bbc30dc7363ddce806ae98192 Mon Sep 17 00:00:00 2001 From: Brett Smith Date: Thu, 5 Mar 2020 13:57:20 -0500 Subject: [PATCH] errors: Add a __repr__. This makes the errors easier to understand in test failures. --- conservancy_beancount/plugin/errors.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/conservancy_beancount/plugin/errors.py b/conservancy_beancount/plugin/errors.py index 59b8525..6bd6842 100644 --- a/conservancy_beancount/plugin/errors.py +++ b/conservancy_beancount/plugin/errors.py @@ -20,6 +20,13 @@ class _BaseError(Exception): self.entry = entry 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): def __init__(self, txn, post, key, value=None, source=None):