Skip to content

Commit a52fe90

Browse files
authored
Merge pull request #7 from OUDON/fix/raise-too-long-error
fix: Raise too long error
2 parents a454470 + bba83ca commit a52fe90

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

src/rmqrcode/console.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,15 @@ def main():
5353
elif args.fit_strategy == 'min_height':
5454
fit_strategy = FitStrategy.MINIMIZE_HEIGHT
5555

56-
qr = _make_qr(
57-
args.DATA,
58-
ecc=ecc,
59-
version=args.version,
60-
fit_strategy=fit_strategy
61-
)
56+
try:
57+
qr = _make_qr(
58+
args.DATA,
59+
ecc=ecc,
60+
version=args.version,
61+
fit_strategy=fit_strategy
62+
)
63+
except DataTooLongError:
64+
_show_error_and_exit("Error: The data is too long.")
6265

6366
_save_image(qr, args.OUTPUT)
6467

src/rmqrcode/rmqrcode.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,9 @@ def _put_data(self, data):
265265
encoded_data = self._convert_to_bites_data(data, character_count_length, codewords_total)
266266
codewords = split_into_8bits(encoded_data)
267267

268+
if len(codewords) > codewords_total:
269+
raise DataTooLongError("The data is too long.")
270+
268271
# codeword数に満たない場合は規定の文字列を付与する
269272
while True:
270273
if len(codewords) >= codewords_total:

0 commit comments

Comments
 (0)