diff options
author | Spartan322 <Megacake1234@gmail.com> | 2024-08-03 23:29:33 +0200 |
---|---|---|
committer | Spartan322 <Megacake1234@gmail.com> | 2024-08-03 23:29:33 +0200 |
commit | 2addc7763556ff76809f14e2063d1452aa9d6275 (patch) | |
tree | 996cac9cfa3c18798b5e509f51935a2538baac3f /src/openvic-dataloader/v2script | |
parent | 2f6f6bdbb191aca01a1c4a9587e314442d219fb4 (diff) |
Fix crash for empty/invalid/not-found filepaths
Add tests to validate empty string path
Add tests to validate non-existent string path
Add tests to validate nullptr buffer parser
Diffstat (limited to 'src/openvic-dataloader/v2script')
-rw-r--r-- | src/openvic-dataloader/v2script/Parser.cpp | 7 |
1 files changed, 2 insertions, 5 deletions
diff --git a/src/openvic-dataloader/v2script/Parser.cpp b/src/openvic-dataloader/v2script/Parser.cpp index e5234d6..9b36a95 100644 --- a/src/openvic-dataloader/v2script/Parser.cpp +++ b/src/openvic-dataloader/v2script/Parser.cpp @@ -77,9 +77,6 @@ struct Parser::ParseHandler final : detail::BasicStateParseHandler<v2script::ast } Parser::error_range get_errors() { - using iterator = typename decltype(std::declval<const error::Root*>()->children())::iterator; - if (!is_valid()) - return dryad::make_node_range<error::Error>(iterator::from_ptr(nullptr), iterator::from_ptr(nullptr)); return parse_state().logger().get_errors(); } }; @@ -146,7 +143,7 @@ constexpr void Parser::_run_load_func(detail::LoadCallback<Parser::ParseHandler* if (!error_message.empty()) { _has_error = true; _has_fatal_error = true; - _parse_handler->parse_state().logger().template create_log<error::BufferError>(DiagnosticLogger::DiagnosticKind::error, fmt::runtime(error_message)); + _parse_handler->parse_state().logger().template create_log<error::BufferError>(DiagnosticLogger::DiagnosticKind::error, fmt::runtime(error_message), _file_path); } if (has_error() && &_error_stream.get() != &detail::cnull) { print_errors_to(_error_stream.get()); @@ -356,7 +353,7 @@ void Parser::print_errors_to(std::basic_ostream<char>& stream) const { dryad::visit_tree( error, [&](const error::BufferError* buffer_error) { - stream << "buffer error: " << this->error(buffer_error) << '\n'; + stream << this->error(buffer_error) << '\n'; }, [&](dryad::child_visitor<error::ErrorKind> visitor, const error::AnnotatedError* annotated_error) { stream << this->error(annotated_error) << '\n'; |