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

throw exception if a file cannot be opened, fix travis-ci builds #117

Merged
merged 4 commits into from
Sep 8, 2019
Merged

throw exception if a file cannot be opened, fix travis-ci builds #117

merged 4 commits into from
Sep 8, 2019

Conversation

thomastrapp
Copy link
Contributor

@thomastrapp thomastrapp commented Aug 27, 2019

  • Add a new function in utils.hpp: open_file_or_throw: This function
    returns an opened std::ifstream or throws by calling inja_throw.
  • Use this function in Parser::load_file which previously returned an
    empty string if the file couldn't be opened.
  • Use this function in Environment::load_json which previously threw
    a nlohmann::detail::parse_error if the file couldn't be opened.
  • In Parser::parse_statement: When including files through include,
    do not attempt to (re-)parse templates from files that were already
    included. Additionally, this prevents inja from attempting to load
    in-memory templates by their name from disk.
  • Add tests that check if an exception is thrown when attempting to
    open files that do not exist.

If there is anything that I can do to get this merged, please let me know.

Edit:
I have re-enabled --std=c++11 with the last two commits. This fixes the travis-ci builds.

* Add a new function in utils.hpp: open_file_or_throw: This function
  returns an opened std::ifstream or throws by calling `inja_throw`.
* Use this function in Parser::load_file which previously returned an
  empty string if the file couldn't be opened.
* Use this function in Environment::load_json which previously threw
  a `nlohmann::detail::parse_error` if the file couldn't be opened.
* In Parser::parse_statement: When including files through `include`,
  do not attempt to (re-)parse templates from files that were already
  included. Additionally, this prevents inja from attempting to load
  in-memory templates by their name from disk.
* Add tests that check if an exception is thrown when attempting to
  open files that do not exist.
@thomastrapp thomastrapp changed the title throw exception if a file cannot be opened throw exception if a file cannot be opened, fix travis-ci builds Aug 30, 2019
@pantor pantor merged commit 419c93c into pantor:master Sep 8, 2019
@pantor
Copy link
Owner

pantor commented Sep 8, 2019

Great, thank you so much!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants