Skip to content

Commit

Permalink
use Throwable to replace Exception
Browse files Browse the repository at this point in the history
  • Loading branch information
ZsgsDesign committed Oct 24, 2021
1 parent d78a39d commit 4f69402
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
7 changes: 4 additions & 3 deletions Crawler.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use KubAT\PhpSimple\HtmlDomParser;
use Requests;
use Exception;
use Throwable;
use Log;

class Crawler extends CrawlerBase
Expand Down Expand Up @@ -63,7 +64,7 @@ public function extractCodeForces($pcode, $url, $retries = 5)
foreach (range(1, $retries) as $tries) {
try {
$status = $this->_extractCodeForces($pcode, $url);
} catch (Exception $e) {
} catch (Throwable $e) {
Log::alert($e);
$this->line("\n <bg=red;fg=white> Exception </> : <fg=yellow>{$e->getMessage()}</>\n");
continue;
Expand Down Expand Up @@ -146,9 +147,9 @@ private function _extractCodeForces($pcode, $url)
}

$sampleTestsDOM = $problemDOM->find('div.problem-statement div.sample-tests', 0);
$sampleTestsDOM->find('div.section-title', 0)->outertext = '';

if (filled($sampleTestsDOM)) {
$sampleTestsDOM->find('div.section-title', 0)->outertext = '';
$sampleCount = intval(count($sampleTestsDOM->find('pre')) / 2);
$samples = [];
for ($i = 0; $i < $sampleCount; $i++) {
Expand Down Expand Up @@ -258,7 +259,7 @@ public function crawl($con, $cached, $incremental, $range)
if ($problemset["status"] != "OK") {
throw new Exception("Contest list status not OK.");
}
} catch (Exception $e) {
} catch (Throwable $e) {
throw new Exception('Failed fetching problem set.');
}

Expand Down
2 changes: 1 addition & 1 deletion babel.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"description": "Codeforces & Gym interface for NOJ",
"license": "MIT",
"repository": "https://github.com/NJUPTAAA/NOJ_Extension_Codeforces",
"version": "0.4.1",
"version": "0.4.2",
"website": "https://codeforces.com/",
"custom": {
"css": "resources/custom.css"
Expand Down

0 comments on commit 4f69402

Please sign in to comment.