Skip to content

Commit 0978b28

Browse files
committed
RegexpException: uses preg_last_error_msg()
1 parent 178deac commit 0978b28

File tree

2 files changed

+1
-9
lines changed

2 files changed

+1
-9
lines changed

src/Utils/Strings.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -667,7 +667,7 @@ public static function pcre(string $func, array $args)
667667
if (($code = preg_last_error()) // run-time error, but preg_last_error & return code are liars
668668
&& ($res === null || !in_array($func, ['preg_filter', 'preg_replace_callback', 'preg_replace'], true))
669669
) {
670-
throw new RegexpException((RegexpException::MESSAGES[$code] ?? 'Unknown error')
670+
throw new RegexpException(preg_last_error_msg()
671671
. ' (pattern: ' . implode(' or ', (array) $args[0]) . ')', $code);
672672
}
673673

src/Utils/exceptions.php

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,6 @@ class JsonException extends \Exception
3939
*/
4040
class RegexpException extends \Exception
4141
{
42-
public const MESSAGES = [
43-
PREG_INTERNAL_ERROR => 'Internal error',
44-
PREG_BACKTRACK_LIMIT_ERROR => 'Backtrack limit was exhausted',
45-
PREG_RECURSION_LIMIT_ERROR => 'Recursion limit was exhausted',
46-
PREG_BAD_UTF8_ERROR => 'Malformed UTF-8 data',
47-
PREG_BAD_UTF8_OFFSET_ERROR => 'Offset didn\'t correspond to the begin of a valid UTF-8 code point',
48-
6 => 'Failed due to limited JIT stack space', // PREG_JIT_STACKLIMIT_ERROR
49-
];
5042
}
5143

5244

0 commit comments

Comments
 (0)