From 701a64cdded5823313d6631d3e6dc206e065c9fa Mon Sep 17 00:00:00 2001 From: David M Penner Date: Tue, 24 Mar 2020 17:48:10 -0400 Subject: [PATCH] Capture dml_write_exceptions from parse_html() --- classes/robot/crawler.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/classes/robot/crawler.php b/classes/robot/crawler.php index 0e8c0829..6fce7faa 100644 --- a/classes/robot/crawler.php +++ b/classes/robot/crawler.php @@ -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";