Skip to content

Commit 8d6e3f9

Browse files
committed
[#561] UPC_A's error message is wrong.
1 parent 91b10a1 commit 8d6e3f9

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

Source/lib/oned/UPCAWriter.cs

+5
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,11 @@ public BitMatrix encode(String contents,
8181
{
8282
throw new ArgumentException("Can only encode UPC-A, but got " + format);
8383
}
84+
int length = contents.Length;
85+
if (length != 11 && length != 12)
86+
{
87+
throw new ArgumentException("Requested contents should be 11 (without checksum digit) or 12 digits long, but got " + length);
88+
}
8489
// Transform a UPC-A code into the equivalent EAN-13 code and write it that way
8590
return subWriter.encode('0' + contents, BarcodeFormat.EAN_13, width, height, hints);
8691
}

0 commit comments

Comments
 (0)