Skip to content
This repository has been archived by the owner on Mar 6, 2022. It is now read-only.

Commit

Permalink
Better diagnostic message from preg_replace on error
Browse files Browse the repository at this point in the history
  • Loading branch information
dantleech committed Apr 22, 2021
1 parent e265b39 commit cd3975a
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lib/Core/Util/OffsetHelper.php
Original file line number Diff line number Diff line change
@@ -3,6 +3,7 @@
namespace Phpactor\Completion\Core\Util;

use RuntimeException;
use function preg_last_error_msg;

class OffsetHelper
{
@@ -12,8 +13,9 @@ public static function lastNonWhitespaceCharacterOffset(string $input): int

if (null === $source) {
throw new RuntimeException(sprintf(
'preg_replace could not parse string "%s"',
$input
'preg_replace could not parse string (size %s): %s',
strlen($input),
preg_last_error_msg()
));
}

0 comments on commit cd3975a

Please sign in to comment.