Skip to content

Commit

Permalink
make qr print a nicer error message on too large inputs
Browse files Browse the repository at this point in the history
  • Loading branch information
guusbertens committed Mar 31, 2023
1 parent d818dd5 commit b92aa7f
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions qrcode/console_scripts.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,11 @@ def raise_error(msg: str) -> NoReturn:
else:
qr.add_data(data, optimize=opts.optimize)

try:
qr.make()
except qrcode.exceptions.DataOverflowError:
raise_error("too much data to fit in QR code")

if opts.output:
img = qr.make_image()
with open(opts.output, "wb") as out:
Expand Down

0 comments on commit b92aa7f

Please sign in to comment.