diff --git a/include/tao/config/internal/config_action.hpp b/include/tao/config/internal/config_action.hpp index 358a4fd..f547281 100644 --- a/include/tao/config/internal/config_action.hpp +++ b/include/tao/config/internal/config_action.hpp @@ -22,6 +22,7 @@ #include "key1_guard.hpp" #include "pegtl.hpp" #include "phase1_append.hpp" +#include "string_utility.hpp" namespace tao::config::internal { @@ -169,11 +170,12 @@ namespace tao::config::internal pegtl::parse_nested< rules::config_file, config_action >( ai.position(), static_cast< pegtl_input_t& >( in ), st, fm ); } catch( const std::system_error& e ) { - if( ( !st.include_is_optional ) || ( e.code().value() != ENOENT ) ) { - throw pegtl::parse_error( "include error", ai.position() ); - // throw pegtl::parse_error( format( __FILE__, __LINE__, "include failed", { { "filename", f }, { "error", e.what() }, { "errno", e.code().value() } } ), pos ); + if( !st.include_is_optional ) { + throw pegtl::parse_error( strcat( "include error: ", e.what() ), ai.position() ); + } + if( e.code().value() != ENOENT ) { + throw pegtl::parse_error( strcat( "include optional error: ", e.what() ), ai.position() ); } - // An optional include file does not exist -- silently ignore and continue with a smile :-) } } }; diff --git a/tests/doc_include.success b/tests/doc_include.success index a292cff..863f0b6 100644 --- a/tests/doc_include.success +++ b/tests/doc_include.success @@ -8,4 +8,4 @@ foo } // Use include? with a non-existing file, not an error. -(include? "tests/non_existing_file_is_no_error_with_include?") +(include? "tests/non_existing_file_is_no_error_with_question_mark")