Updated QrCode.encodeSegments() to throw DataTooLongException - in Java, C++, Python, Rust code. Rust code also changes return types from Option to Result. Updated Java and Rust documentation.

This commit is contained in:
Project Nayuki
2018-10-26 02:42:04 +00:00
parent 4635e8a8a8
commit 8da8107cc2
4 changed files with 43 additions and 21 deletions
+4 -1
View File
@@ -124,7 +124,10 @@ class QrCode(object):
if datausedbits is not None and datausedbits <= datacapacitybits:
break # This version number is found to be suitable
if version >= maxversion: # All versions in the range could not fit the given data
raise ValueError("Data too long")
msg = "Segment too long"
if datausedbits is not None:
msg = "Data length = {} bits, Max capacity = {} bits".format(datausedbits, datacapacitybits)
raise DataTooLongError(msg)
if datausedbits is None:
raise AssertionError()