Commit 308b40b8 authored by Jorgen's avatar Jorgen

Add error handling when searching for typo context

parent 4fd6c29a
.idea/
vendor/
.vscode/
\ No newline at end of file
......@@ -79,8 +79,15 @@ abstract class TyposClientInterface
// Find a context in text, capture it offset
$contextMatch = [];
preg_match_all("#{$context}#", $text, $contextMatch, PREG_OFFSET_CAPTURE);
error_log("Context match = " . print_r($contextMatch, true));
$contextMatch = $contextMatch[0];
if (!isset($contextMatch[0])) {
throw new \Exception("Failed to find the context in article");
}
$contextOffset = $contextMatch[0][1];
// Find a concrete typo that we want to fix
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment