Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

What is the proper way to check for a missing file #90

Closed
burki opened this issue Jan 21, 2020 · 2 comments
Closed

What is the proper way to check for a missing file #90

burki opened this issue Jan 21, 2020 · 2 comments
Assignees
Projects
Milestone

Comments

@burki
Copy link

burki commented Jan 21, 2020

This is more a question than an error.

I'm calling $xml = \FluentDOM::load($fname, 'xml', [ \FluentDOM\Loader\Options::ALLOW_FILE => true ]); on a non-existing $fname and then get a valid document with

<?xml version="1.0" encoding="UTF-8"?>

when I call $xml->saveXML().

I checked both the wiki and the source and couldn't find the proper way to catch this besides calling file_exists() or something similar on $fname before calling the loader.

It would be great if there was a way to somehow check the return-value (TRUE or FALSE) of $document->load($source, $settings[Options::LIBXML_OPTIONS]); (https://github.com/ThomasWeinert/FluentDOM/blob/master/src/FluentDOM/Loader/Supports/Libxml.php#L59) or if $document was returned as NULL when $document-load() returns FALSE (either always or through an additional loader option).

@ThomasWeinert
Copy link
Owner

ThomasWeinert commented Jan 27, 2020

Here is no explicit handling for that.

I should implement some proper exceptions for that.

@ThomasWeinert ThomasWeinert added this to In progress in FluentDOM Feb 20, 2021
@ThomasWeinert ThomasWeinert added this to the 8.0 milestone Mar 17, 2021
@ThomasWeinert
Copy link
Owner

This will now throw an FileNotLoaded exception

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
FluentDOM
In progress
Development

No branches or pull requests

2 participants