Skip to content

Commit

Permalink
Catch exception from method.
Browse files Browse the repository at this point in the history
Signed-off-by: Mior Muhammad Zaki <crynobone@gmail.com>
  • Loading branch information
crynobone committed Jun 25, 2019
1 parent 38d9f8d commit 225e1d2
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/Xml/Reader.php
Expand Up @@ -2,6 +2,7 @@

namespace Laravie\Parser\Xml;

use Throwable;
use Laravie\Parser\Reader as BaseReader;
use Laravie\Parser\FileNotFoundException;
use Laravie\Parser\InvalidContentException;
Expand All @@ -14,7 +15,11 @@ class Reader extends BaseReader
*/
public function extract(string $content): BaseDocument
{
$xml = @\simplexml_load_string($content);
try {
$xml = @\simplexml_load_string($content);
} catch (Throwable $e) {
$xml = null;
}

return $this->resolveXmlObject($xml);
}
Expand All @@ -24,7 +29,11 @@ public function extract(string $content): BaseDocument
*/
public function load(string $filename): BaseDocument
{
$xml = @\simplexml_load_file($filename);
try {
$xml = @\simplexml_load_file($filename);
} catch (Throwable $e) {
$xml = null;
}

return $this->resolveXmlObject($xml);
}
Expand Down

0 comments on commit 225e1d2

Please sign in to comment.