Skip to content

Commit

Permalink
url: Expose ValidationError descriptions
Browse files Browse the repository at this point in the history
  • Loading branch information
robinlinden committed Dec 17, 2023
1 parent 8cc56c5 commit 8dfa042
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
6 changes: 5 additions & 1 deletion url/url.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -298,13 +298,17 @@ void UrlParser::validation_error(ValidationError err) const {
on_error_(err);
}

std::string_view description(ValidationError e) {
return validation_error_str.at(e);
}

UrlParser::UrlParser() : util::BaseParser("") {
set_on_error([this](ValidationError e) {
spdlog::warn("url: InputPos: {}, ParserState: {}, Validation Error: {} {}",
current_pos(),
std::to_underlying(state_),
std::to_underlying(e),
validation_error_str.at(e));
description(e));
});
}

Expand Down
2 changes: 2 additions & 0 deletions url/url.h
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,8 @@ enum class ValidationError {
FileInvalidWindowsDriveLetterHost
};

std::string_view description(ValidationError);

// This parser is current with the WHATWG URL specification as of 27 September 2023
class UrlParser final : util::BaseParser {
public:
Expand Down

0 comments on commit 8dfa042

Please sign in to comment.