Skip to content

Commit

Permalink
Catch fatal errors and add context in exception
Browse files Browse the repository at this point in the history
  • Loading branch information
dantleech committed Mar 29, 2024
1 parent 7f00bf8 commit f504fe3
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions lib/Indexer/Adapter/Tolerant/TolerantIndexBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
use Phpactor\TextDocument\TextDocument;
use Psr\Log\LoggerInterface;
use Psr\Log\NullLogger;
use RuntimeException;
use Throwable;

final class TolerantIndexBuilder implements IndexBuilder
{
Expand Down Expand Up @@ -86,6 +88,12 @@ private function indexNode(TextDocument $document, Node $node): void
$document->uri()?->__toString() ?? 'unknown',
$cannotIndexNode->getMessage()
));
} catch (Throwable $cannotIndexNode) {
throw new RuntimeException(sprintf(
'Could not index document "%s": %s',
$document->uri() ?? '',
$cannotIndexNode->getMessage()
), 0, $cannotIndexNode);
}
}

Expand Down

0 comments on commit f504fe3

Please sign in to comment.