Skip to content

Commit

Permalink
Fix exception messages: these showed e.g.
Browse files Browse the repository at this point in the history
"The cm operator must pass 6 numbers. Instead got: Decimal[]"
instead of
"The cm operator must pass 6 numbers. Instead got: 4"
  • Loading branch information
Mark van 't Zet committed Sep 12, 2023
1 parent ee75608 commit a19601b
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ protected override void ApplyOperation(CompactFontFormatTopLevelDictionary dicti
}
else
{
throw new InvalidOperationException($"Expected four values for the font matrix, instead got: {array}.");
throw new InvalidOperationException($"Expected four values for the font matrix, instead got: {array.Length}.");
}
}
break;
Expand Down
2 changes: 1 addition & 1 deletion src/UglyToad.PdfPig/AcroForms/AcroFormFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,7 @@ private AcroFieldBase GetChoiceField(DictionaryToken fieldDictionary, NameToken
{
if (optionArrayToken.Length != 2)
{
throw new PdfDocumentFormatException($"An option array containing array elements should contain 2 strings, instead got: {optionArrayToken}.");
throw new PdfDocumentFormatException($"An option array containing array elements should contain 2 strings, instead got: {optionArrayToken.Length}.");
}

string exportValue;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public ModifyCurrentTransformationMatrix(decimal[] value)

if (value.Length != 6)
{
throw new ArgumentException("The cm operator must pass 6 numbers. Instead got: " + value);
throw new ArgumentException("The cm operator must pass 6 numbers. Instead got: " + value.Length);
}
Value = value;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public SetTextMatrix(decimal[] value)
{
if (value.Length != 6)
{
throw new ArgumentException("Text matrix must provide 6 values. Instead got: " + value);
throw new ArgumentException("Text matrix must provide 6 values. Instead got: " + value.Length);
}

Value = value;
Expand Down
4 changes: 2 additions & 2 deletions src/UglyToad.PdfPig/Util/DictionaryTokenExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ public static PdfRectangle ToRectangle(this ArrayToken array, IPdfTokenScanner t

if (array.Data.Count != 4)
{
throw new PdfDocumentFormatException($"Cannot convert array to rectangle, expected 4 values instead got: {array}.");
throw new PdfDocumentFormatException($"Cannot convert array to rectangle, expected 4 values instead got: {array.Data.Count}.");
}

return new PdfRectangle(DirectObjectFinder.Get<NumericToken>(array[0], tokenScanner).Double,
Expand All @@ -187,7 +187,7 @@ public static PdfRectangle ToIntRectangle(this ArrayToken array, IPdfTokenScanne

if (array.Data.Count != 4)
{
throw new PdfDocumentFormatException($"Cannot convert array to rectangle, expected 4 values instead got: {array}.");
throw new PdfDocumentFormatException($"Cannot convert array to rectangle, expected 4 values instead got: {array.Data.Count}.");
}

return new PdfRectangle(DirectObjectFinder.Get<NumericToken>(array[0], tokenScanner).Int,
Expand Down

0 comments on commit a19601b

Please sign in to comment.