exception catch fixes
This commit is contained in:
parent
058f103812
commit
95af2c5ec9
|
@ -43,6 +43,7 @@ abstract class Source {
|
||||||
$this->parse();
|
$this->parse();
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
echo 'Caught exception: ', $e->getMessage(), "\n";
|
echo 'Caught exception: ', $e->getMessage(), "\n";
|
||||||
|
echo $e->getTraceAsString();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$this->endSection();
|
$this->endSection();
|
||||||
|
|
|
@ -23,7 +23,7 @@ class Anivisual extends Source {
|
||||||
$text = $this->get_text('http://anivisual.net/stuff/1');
|
$text = $this->get_text('http://anivisual.net/stuff/1');
|
||||||
try {
|
try {
|
||||||
$this->dom->loadStr($text, []);
|
$this->dom->loadStr($text, []);
|
||||||
} catch (Exception $e) {
|
} catch (\Exception $e) {
|
||||||
echo $e->getMessage();
|
echo $e->getMessage();
|
||||||
echo $e->getTraceAsString();
|
echo $e->getTraceAsString();
|
||||||
return "";
|
return "";
|
||||||
|
|
|
@ -9,7 +9,7 @@ class Hyperbook extends Source {
|
||||||
$text = $this->get_text('http://hyperbook.ru/lib.php?sort=time');
|
$text = $this->get_text('http://hyperbook.ru/lib.php?sort=time');
|
||||||
try {
|
try {
|
||||||
$this->dom->loadStr($text, []);
|
$this->dom->loadStr($text, []);
|
||||||
} catch (Exception $e) {
|
} catch (\Exception $e) {
|
||||||
echo $e->getMessage();
|
echo $e->getMessage();
|
||||||
echo $e->getTraceAsString();
|
echo $e->getTraceAsString();
|
||||||
return "";
|
return "";
|
||||||
|
@ -19,7 +19,7 @@ class Hyperbook extends Source {
|
||||||
$games = [];
|
$games = [];
|
||||||
try {
|
try {
|
||||||
$headings = $container->find("h3");
|
$headings = $container->find("h3");
|
||||||
} catch ( Exception $e ) {
|
} catch (\Exception $e ) {
|
||||||
echo $e->getMessage();
|
echo $e->getMessage();
|
||||||
echo $e->getTraceAsString();
|
echo $e->getTraceAsString();
|
||||||
return "";
|
return "";
|
||||||
|
|
|
@ -13,10 +13,10 @@ class Steam extends Source {
|
||||||
'displayterm' => $tag,
|
'displayterm' => $tag,
|
||||||
'category1' => 998, // only games
|
'category1' => 998, // only games
|
||||||
]);
|
]);
|
||||||
$text = $this->get_text($url);
|
|
||||||
try {
|
try {
|
||||||
|
$text = $this->get_text($url);
|
||||||
$this->dom->loadStr($text, []);
|
$this->dom->loadStr($text, []);
|
||||||
} catch (Exception $e) {
|
} catch (\Exception $e) {
|
||||||
echo $e->getMessage();
|
echo $e->getMessage();
|
||||||
echo $e->getTraceAsString();
|
echo $e->getTraceAsString();
|
||||||
return "";
|
return "";
|
||||||
|
@ -25,17 +25,24 @@ class Steam extends Source {
|
||||||
$games = $this->dom->find('#search_result_container a.search_result_row');
|
$games = $this->dom->find('#search_result_container a.search_result_row');
|
||||||
foreach ($games as $gameLink) {
|
foreach ($games as $gameLink) {
|
||||||
$url = $gameLink->getAttribute('href');
|
$url = $gameLink->getAttribute('href');
|
||||||
$text = $this->get_text($url);
|
|
||||||
try {
|
|
||||||
$this->dom->loadStr($text, []);
|
|
||||||
} catch (Exception $e) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
unset($text);
|
|
||||||
$game = new Game;
|
$game = new Game;
|
||||||
$game->title = $this->dom->find('.apphub_AppName')->innerHtml;
|
|
||||||
$game->description = $this->dom->find('.game_description_snippet')->innerHtml;
|
|
||||||
$game->url = $url;
|
$game->url = $url;
|
||||||
|
try {
|
||||||
|
$text = $this->get_text($url);
|
||||||
|
$this->dom->loadStr($text, []);
|
||||||
|
unset($text);
|
||||||
|
$name = $this->dom->find('.apphub_AppName');
|
||||||
|
$description = $this->dom->find('.game_description_snippet');
|
||||||
|
try {
|
||||||
|
$game->title = $name->innerHtml;
|
||||||
|
$game->description = $description->innerHtml;
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
echo 'No title or description found for '.$url.PHP_EOL;
|
||||||
|
}
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
echo $e->getMessage();
|
||||||
|
echo $e->getTraceAsString();
|
||||||
|
}
|
||||||
$this->output .= $game->print();
|
$this->output .= $game->print();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,7 +37,7 @@ class Textadventures extends Source {
|
||||||
$desc
|
$desc
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
} catch (Exception $e) {} // probably a 18+ game, no info on game page
|
} catch (\Exception $e) {} // probably a 18+ game, no info on game page
|
||||||
|
|
||||||
$this->output .= $game->print();
|
$this->output .= $game->print();
|
||||||
}
|
}
|
||||||
|
|
Reference in a new issue