summaryrefslogtreecommitdiff
path: root/app/Report/ReportParserBase.php
diff options
context:
space:
mode:
authorGreg Roach <fisharebest@webtrees.net>2018-10-10 11:31:21 +0100
committerGreg Roach <fisharebest@webtrees.net>2018-10-10 11:31:21 +0100
commit7774ce417b2d279a299363f4077137e95666ac0f (patch)
tree06730b37acc7e74c62790bd1cb8317091cad7539 /app/Report/ReportParserBase.php
parent8784bbca00d6ad162b0cf236304211463cfa3b12 (diff)
downloadwebtrees-7774ce417b2d279a299363f4077137e95666ac0f.tar.gz
webtrees-7774ce417b2d279a299363f4077137e95666ac0f.tar.bz2
webtrees-7774ce417b2d279a299363f4077137e95666ac0f.zip
Error handling
Diffstat (limited to 'app/Report/ReportParserBase.php')
-rw-r--r--app/Report/ReportParserBase.php9
1 files changed, 9 insertions, 0 deletions
diff --git a/app/Report/ReportParserBase.php b/app/Report/ReportParserBase.php
index a9973c1e89..5e3ec78c45 100644
--- a/app/Report/ReportParserBase.php
+++ b/app/Report/ReportParserBase.php
@@ -18,6 +18,7 @@ declare(strict_types=1);
namespace Fisharebest\Webtrees\Report;
use DomainException;
+use Exception;
/**
* Class ReportParserBase
@@ -34,6 +35,8 @@ class ReportParserBase
* Create a parser for a report
*
* @param string $report The XML filename
+ *
+ * @throws Exception
*/
public function __construct(string $report)
{
@@ -60,6 +63,10 @@ class ReportParserBase
$fp = fopen($report, 'r');
+ if ($fp === false) {
+ throw new Exception('Cannot open ' . $report);
+ }
+
while (($data = fread($fp, 4096))) {
if (!xml_parse($this->xml_parser, $data, feof($fp))) {
throw new DomainException(sprintf(
@@ -70,6 +77,8 @@ class ReportParserBase
}
}
+ fclose($fp);
+
xml_parser_free($this->xml_parser);
}