diff --git a/Source.php b/Source.php index 43a9bd7..16cebfb 100644 --- a/Source.php +++ b/Source.php @@ -43,6 +43,7 @@ abstract class Source { $this->parse(); } catch (\Exception $e) { echo 'Caught exception: ', $e->getMessage(), "\n"; + echo $e->getTraceAsString(); return; } $this->endSection(); diff --git a/Source/Anivisual.php b/Source/Anivisual.php index 28d339b..a5ca4e6 100644 --- a/Source/Anivisual.php +++ b/Source/Anivisual.php @@ -23,7 +23,7 @@ class Anivisual extends Source { $text = $this->get_text('http://anivisual.net/stuff/1'); try { $this->dom->loadStr($text, []); - } catch (Exception $e) { + } catch (\Exception $e) { echo $e->getMessage(); echo $e->getTraceAsString(); return ""; diff --git a/Source/Hyperbook.php b/Source/Hyperbook.php index c014e46..a94823a 100644 --- a/Source/Hyperbook.php +++ b/Source/Hyperbook.php @@ -9,7 +9,7 @@ class Hyperbook extends Source { $text = $this->get_text('http://hyperbook.ru/lib.php?sort=time'); try { $this->dom->loadStr($text, []); - } catch (Exception $e) { + } catch (\Exception $e) { echo $e->getMessage(); echo $e->getTraceAsString(); return ""; @@ -19,7 +19,7 @@ class Hyperbook extends Source { $games = []; try { $headings = $container->find("h3"); - } catch ( Exception $e ) { + } catch (\Exception $e ) { echo $e->getMessage(); echo $e->getTraceAsString(); return ""; diff --git a/Source/Steam.php b/Source/Steam.php index ad1a3d0..acda972 100644 --- a/Source/Steam.php +++ b/Source/Steam.php @@ -13,10 +13,10 @@ class Steam extends Source { 'displayterm' => $tag, 'category1' => 998, // only games ]); - $text = $this->get_text($url); try { + $text = $this->get_text($url); $this->dom->loadStr($text, []); - } catch (Exception $e) { + } catch (\Exception $e) { echo $e->getMessage(); echo $e->getTraceAsString(); return ""; @@ -25,17 +25,24 @@ class Steam extends Source { $games = $this->dom->find('#search_result_container a.search_result_row'); foreach ($games as $gameLink) { $url = $gameLink->getAttribute('href'); - $text = $this->get_text($url); - try { - $this->dom->loadStr($text, []); - } catch (Exception $e) { - continue; - } - unset($text); $game = new Game; - $game->title = $this->dom->find('.apphub_AppName')->innerHtml; - $game->description = $this->dom->find('.game_description_snippet')->innerHtml; $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(); } } diff --git a/Source/Textadventures.php b/Source/Textadventures.php index be1d54a..ed5e8fa 100644 --- a/Source/Textadventures.php +++ b/Source/Textadventures.php @@ -37,7 +37,7 @@ class Textadventures extends Source { $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(); }