Skip to content

Commit dccd820

Browse files
committed
Use custom message if any was supplied; otherwise use the message raised
1 parent 8a9c726 commit dccd820

1 file changed

Lines changed: 11 additions & 7 deletions

File tree

src/Assert/DateTimeTrait.php

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
namespace SimpleSAML\WebServices\Security\Assert;
66

7+
use SimpleSAML\Assert\AssertionFailedException;
78
use SimpleSAML\WebServices\Security\Exception\ProtocolViolationException;
89

910
/**
@@ -17,12 +18,15 @@ trait DateTimeTrait
1718
*/
1819
protected static function validDateTime(string $value, string $message = ''): void
1920
{
20-
parent::validDateTime($value);
21-
parent::endsWith(
22-
$value,
23-
'Z',
24-
'%s is not a DateTime expressed in the UTC timezone using the \'Z\' timezone identifier.',
25-
ProtocolViolationException::class,
26-
);
21+
try {
22+
parent::validDateTime($value);
23+
parent::endsWith(
24+
$value,
25+
'Z',
26+
'%s is not a DateTime expressed in the UTC timezone using the \'Z\' timezone identifier.',
27+
);
28+
} catch (AssertionFailedException $e) {
29+
throw new ProtocolViolationException($message ?: $e->getMessage());
30+
}
2731
}
2832
}

0 commit comments

Comments
 (0)