Skip to content

Commit 690d700

Browse files
committed
ConsistencyError: swap params to match the error message
This will make the correspondence between the line of code where the exception is thrown and the error message less confusing. Currently, the stack trace looks like this: ``` Traceback (most recent call last): (...) File "(...)\vlq_base128_le.py", line 85, in _check raise kaitaistruct.ConsistencyError(u"groups", self.groups[i]._root, self._root) kaitaistruct.ConsistencyError: Check failed: groups, expected: <vlq_base128_le.VlqBase128Le object at 0x0000025E86955CA0>, actual: None ``` At first glance, it might seem that `self.groups[i]._root` was the "expected" value and `self._root` was the "actual" value, but it's actually the other way around. This doesn't seem very intuitive. In addition, the new order `expected, actual` is already used in ValidationNotEqualError, so using the opposite order here seems inconsistent.
1 parent fa6fbd5 commit 690d700

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

kaitaistruct.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1008,11 +1008,11 @@ def __init__(self, actual, io, src_path):
10081008

10091009

10101010
class ConsistencyError(Exception):
1011-
def __init__(self, attr_id, actual, expected):
1011+
def __init__(self, attr_id, expected, actual):
10121012
super(ConsistencyError, self).__init__("Check failed: %s, expected: %s, actual: %s" % (attr_id, repr(expected), repr(actual)))
10131013
self.id = attr_id
1014-
self.actual = actual
10151014
self.expected = expected
1015+
self.actual = actual
10161016

10171017

10181018
class ConsistencyNotCheckedError(Exception):

0 commit comments

Comments
 (0)