Skip to content

Commit

Permalink
Merge pull request #21 from miqwit/bugfix/errors-as-exceptions
Browse files Browse the repository at this point in the history
raise an exception when Error occurs, like TypeError
  • Loading branch information
miqwit authored Jan 27, 2023
2 parents c273923 + ac53949 commit 9d97649
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/Controller/ErnParserController.php
Original file line number Diff line number Diff line change
Expand Up @@ -772,10 +772,16 @@ public function parse(string $file_path) {

// Parse XML now
while ($data = fread($fp, 4096)) {
if (!xml_parse($this->xml_parser, $data, feof($fp))) {
try {
if (!xml_parse($this->xml_parser, $data, feof($fp))) {
throw new XmlParseException(sprintf("XML Error: %s at line %d\n",
xml_error_string(xml_get_error_code($this->xml_parser)),
xml_get_current_line_number($this->xml_parser)));
}
} catch (\Error $er) {
throw new XmlParseException(sprintf("XML Error: %s at line %d\n",
xml_error_string(xml_get_error_code($this->xml_parser)),
xml_get_current_line_number($this->xml_parser)));
$er->getMessage(),
$er->getLine()));
}
}

Expand Down

0 comments on commit 9d97649

Please sign in to comment.