Skip to content

Commit 587409e

Browse files
committed
Improve error messages
1 parent b240666 commit 587409e

File tree

7 files changed

+13
-10
lines changed

7 files changed

+13
-10
lines changed

src/XML/SignableElementTrait.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ public function sign(
8585
C::C14N_EXCLUSIVE_WITH_COMMENTS,
8686
C::C14N_EXCLUSIVE_WITHOUT_COMMENTS,
8787
],
88-
'Unsupported canonicalization algorithm',
88+
'Unsupported canonicalization algorithm: %s',
8989
UnsupportedAlgorithmException::class,
9090
);
9191
$this->c14nAlg = $canonicalizationAlg;

src/XML/ds/CanonicalizationMethod.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ private function setAlgorithm(string $algorithm): void
6464
C::C14N_INCLUSIVE_WITH_COMMENTS,
6565
C::C14N_INCLUSIVE_WITHOUT_COMMENTS,
6666
],
67-
'Invalid canonicalization method',
67+
'Invalid canonicalization method: %s',
6868
InvalidArgumentException::class,
6969
);
7070

src/XML/ds/DigestMethod.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ private function setAlgorithm(string $algorithm): void
6767
Assert::oneOf(
6868
$algorithm,
6969
array_keys(C::$DIGEST_ALGORITHMS),
70-
'Invalid digest method',
70+
'Invalid digest method: %s',
7171
InvalidArgumentException::class,
7272
);
7373

src/XML/ds/SignatureMethod.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ private function setAlgorithm(string $algorithm): void
6262
array_keys(C::$RSA_DIGESTS),
6363
array_keys(C::$HMAC_DIGESTS),
6464
),
65-
'Invalid signature method',
65+
'Invalid signature method: %s',
6666
InvalidArgumentException::class,
6767
);
6868

src/XML/ds/Transform.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ private function setXPath(?XPath $xpath): void
109109
Assert::nullOrEq(
110110
$this->algorithm,
111111
C::XPATH_URI,
112-
'Transform algorithm "' . C::XPATH_URI . '" required if XPath provided.',
112+
sprintf('Transform algorithm "%s" required if XPath provided.', C::XPATH_URI),
113113
);
114114
$this->xpath = $xpath;
115115
}
@@ -143,8 +143,11 @@ private function setInclusiveNamespaces(?InclusiveNamespaces $inclusiveNamespace
143143
C::C14N_INCLUSIVE_WITH_COMMENTS,
144144
C::C14N_EXCLUSIVE_WITHOUT_COMMENTS,
145145
],
146-
'Transform algorithm "' . C::C14N_EXCLUSIVE_WITH_COMMENTS . '" or "' .
147-
C::C14N_EXCLUSIVE_WITHOUT_COMMENTS . '" required if InclusiveNamespaces provided.',
146+
sprintf(
147+
'Transform algorithm "%s" or "%s" required if InclusiveNamespaces provided.',
148+
C::C14N_EXCLUSIVE_WITH_COMMENTS,
149+
C::C14N_EXCLUSIVE_WITHOUT_COMMENTS
150+
),
148151
);
149152

150153
$this->inclusiveNamespaces = $inclusiveNamespaces;

src/XML/dsig11/X509Digest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ private function setAlgorithm(string $algorithm): void
6565
Assert::oneOf(
6666
$algorithm,
6767
array_keys(C::$DIGEST_ALGORITHMS),
68-
'Invalid digest method',
68+
'Invalid digest method: %s',
6969
InvalidArgumentException::class,
7070
);
7171

src/XML/xenc/CipherData.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,15 +105,15 @@ public static function fromXML(DOMElement $xml): static
105105
Assert::maxCount(
106106
$cv,
107107
1,
108-
'More than one CipherValue element in <xenc:CipherData',
108+
'More than one CipherValue element in <xenc:CipherData>',
109109
TooManyElementsException::class
110110
);
111111

112112
$cr = CipherReference::getChildrenOfClass($xml);
113113
Assert::maxCount(
114114
$cr,
115115
1,
116-
'More than one CipherReference element in <xenc:CipherData',
116+
'More than one CipherReference element in <xenc:CipherData>',
117117
TooManyElementsException::class
118118
);
119119

0 commit comments

Comments
 (0)