Skip to content

Commit

Permalink
Capture dml_write_exceptions from parse_html()
Browse files Browse the repository at this point in the history
  • Loading branch information
pennedav authored and brendanheywood committed May 29, 2020
1 parent 5b8280a commit 701a64c
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion classes/robot/crawler.php
Original file line number Diff line number Diff line change
Expand Up @@ -619,7 +619,15 @@ public function crawl($node, $verbose = false) {
// Look for new links on this page from the html.
// Insert new links into tool_crawler_edge, and into tool_crawler_url table.
// Find the course, cm, and context of where we are for the main scraped URL.
$this->parse_html($result, $result->externalurl, $verbose);
try {
$this->parse_html($result, $result->externalurl, $verbose);
} catch (\dml_write_exception $e) {
mtrace("Database write error while processing page '{$result->url}'");
if ($verbose) {
mtrace("Exception: <" . get_class($e) . ">: \"" . $e->getMessage() . "\" in {$e->getFile()} at line {$e->getLine()}");
mtrace("Trace:\n{$e->getTraceAsString()}");
}
}
} else {
if ($verbose) {
echo "NOT html\n";
Expand Down

0 comments on commit 701a64c

Please sign in to comment.