Merge pull request #150 from mithro/better-error

Improve error message.
This commit is contained in:
Clifford Wolf 2018-06-05 17:10:00 +02:00 committed by GitHub
commit 7bb3a5c565
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 10 additions and 3 deletions

View File

@ -509,7 +509,6 @@ def logic_expression_to_lut(s, args):
for j in range(len(args)))) else '0'
for i in range(1 << len(args)))
class ParseError(Exception):
pass
@ -749,11 +748,19 @@ class Tile:
bits_set.add((int(match.group(2)), int(match.group(3))))
if set.intersection(bits_set, bits_clear):
raise ValueError("trying to set/clear the same bit(s) at once")
raise ValueError(
"trying to set/clear the same bit(s) at once set:{} clear:{}".format(
bits_set, bits_clear))
if set.intersection(bits_set, self.bits_cleared) or \
set.intersection(bits_clear, self.bits_set):
raise ParseError("conflicting bits")
raise ParseError("""\
conflicting bits {}
setting:{:<30} - current clear:{}
clearing:{:<30} - current set :{}""".format(
bits,
str(bits_set), self.bits_cleared,
str(bits_clear), self.bits_set))
self.bits_set.update(bits_set)
self.bits_cleared.update(bits_clear)