diff --git a/CHANGELOG.md b/CHANGELOG.md index 9a174b4..e634cb3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ ### Changed - Requires PHP `8.5` +- Exception messages raised in `RegExp` now uses `preg_last_error_msg()` for better debuggability ### Fixed diff --git a/src/RegExp.php b/src/RegExp.php index 291f626..5053f5a 100644 --- a/src/RegExp.php +++ b/src/RegExp.php @@ -20,7 +20,7 @@ private function __construct(string $pattern) /** @psalm-suppress ArgumentTypeCoercion */ if (@\preg_match($pattern, '') === false) { /** @psalm-suppress ImpureFunctionCall */ - throw new LogicException($pattern, \preg_last_error()); + throw new LogicException(\preg_last_error_msg(), \preg_last_error()); } $this->pattern = $pattern; @@ -46,7 +46,7 @@ public function matches(Str $string): bool if ($value === false) { /** @psalm-suppress ImpureFunctionCall */ - throw new InvalidRegex('', \preg_last_error()); + throw new InvalidRegex(\preg_last_error_msg(), \preg_last_error()); } return (bool) $value; @@ -66,7 +66,7 @@ public function capture(Str $string): Map if ($value === false) { /** @psalm-suppress ImpureFunctionCall */ - throw new InvalidRegex('', \preg_last_error()); + throw new InvalidRegex(\preg_last_error_msg(), \preg_last_error()); } /** @var Map */