Skip to content

Commit

Permalink
Store a null count if parsing XML fails, instead of killing entire run
Browse files Browse the repository at this point in the history
  • Loading branch information
gapple committed Nov 24, 2013
1 parent 3c90c66 commit 3582a32
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
15 changes: 13 additions & 2 deletions src/DrupalReleaseDate/DrupalIssueCount.php
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,12 @@ public function getCounts($commonParameters, $fetchSet, $viewClass) {
foreach ($fetchParameters as $parameterKey => $parameterValue) {
$query->set($parameterKey, $parameterValue);
}
$results[$fetchKey] = $this->getCount($request, $viewClass);
try {
$results[$fetchKey] = $this->getCount($request, $viewClass);
}
catch (DrupalOrgParseException $e) {
$results[$fetchKey] = null;
}
}

return $results;
Expand Down Expand Up @@ -277,7 +282,13 @@ public function getXmlDocument(\Guzzle\Http\Message\Response $response) {
);
$page = str_replace(array_keys($replace), array_values($replace), $page);

$document = new \SimpleXMLElement($page);
try {
$document = new \SimpleXMLElement($page);
}
catch (\Exception $e) {
// Throw a better specified Exception.
throw new DrupalOrgParseException();
}
}

// Need to register name for default namespace to be able to query anything with xpath
Expand Down
7 changes: 7 additions & 0 deletions src/DrupalReleaseDate/DrupalOrgParseException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?php
namespace DrupalReleaseDate;

class DrupalOrgParseException extends \RuntimeException
{

}

0 comments on commit 3582a32

Please sign in to comment.