Skip to content

Feature: Better error messages #22

Closed
@Murmele

Description

@Murmele

Currently only a validity_error() is thrown if the dbc file is not correct. Maybe introducing an enum which will be returned with the error to indicate where the error is located and a function to convert the enum to a string error message.

dbc_parser_cpp/src/dbc.cpp

Lines 204 to 250 in 753119d

Message::ParseSignalsStatus DbcParser::parseMessage(const uint32_t id, const std::vector<uint8_t>& data, std::vector<double>& out_values) {
for (const auto& message : messages) {
if (message.id() == id) {
return message.parseSignals(data, out_values);
}
}
return Message::ParseSignalsStatus::ErrorUnknownID;
}
void DbcParser::parse_dbc_header(std::istream& file_stream) {
std::string line;
std::smatch match;
utils::StreamHandler::get_line(file_stream, line);
if (!std::regex_search(line, match, version_re)) {
throw validity_error();
}
version = match.str(2);
utils::StreamHandler::get_next_non_blank_line(file_stream, line);
utils::StreamHandler::skip_to_next_blank_line(file_stream, line);
utils::StreamHandler::get_next_non_blank_line(file_stream, line);
if (!std::regex_search(line, match, bit_timing_re)) {
throw validity_error();
}
}
void DbcParser::parse_dbc_nodes(std::istream& file_stream) {
std::string line;
std::smatch match;
utils::StreamHandler::get_next_non_blank_line(file_stream, line);
if (!std::regex_search(line, match, node_re)) {
throw validity_error();
}
if (match.length() > 2) {
std::string n = match.str(2);
utils::String::split(n, nodes);
}
}
void DbcParser::parse_dbc_messages(const std::vector<std::string>& lines) {

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions