Fix 3dblox parser error#10089
Fix 3dblox parser error#10089openroad-ci wants to merge 3 commits intoThe-OpenROAD-Project:masterfrom
Conversation
Signed-off-by: Jorge Ferreira <jorge.ferreira@precisioninno.com>
|
clang-tidy review says "All clean, LGTM! 👍" |
There was a problem hiding this comment.
Code Review
This pull request enhances error reporting by automatically including the file path in BaseParser::logError and updating derived parsers to avoid redundant filename logging. Feedback suggests utilizing the logger's formatting capabilities in baseParser.cpp to avoid manual string concatenation and removing repetitive 'Parser Error' prefixes in the calls from dbvParser.cpp and dbxParser.cpp to prevent redundant output.
src/odb/src/3dblox/baseParser.cpp
Outdated
| std::string msg = message; | ||
| if (!current_file_path_.empty()) { | ||
| msg = "in " + current_file_path_ + ": " + message; | ||
| } | ||
| logger_->error(utl::ODB, 521, "Parser Error: {} ", msg); |
There was a problem hiding this comment.
The error message construction contains an unnecessary trailing space in the format string and involves manual string concatenation. It is cleaner to use the logger's formatting capabilities directly to include the file path context. Note that calls to logger_->error are expected to terminate the program, so additional error handling is not necessary.
| std::string msg = message; | |
| if (!current_file_path_.empty()) { | |
| msg = "in " + current_file_path_ + ": " + message; | |
| } | |
| logger_->error(utl::ODB, 521, "Parser Error: {} ", msg); | |
| if (!current_file_path_.empty()) { | |
| logger_->error(utl::ODB, 521, "Parser Error in {}: {}", current_file_path_, message); | |
| } else { | |
| logger_->error(utl::ODB, 521, "Parser Error: {}", message); | |
| } |
References
- Calls to logger_->error are expected to terminate the program, so additional error handling like returning an error code or throwing an exception is not necessary.
src/odb/src/3dblox/dbvParser.cpp
Outdated
| std::ifstream file(filename); | ||
| if (!file.is_open()) { | ||
| logError("3DBV Parser Error: Cannot open file: " + filename); | ||
| logError("3DBV Parser Error: Cannot open file"); |
There was a problem hiding this comment.
src/odb/src/3dblox/dbxParser.cpp
Outdated
| std::ifstream file(filename); | ||
| if (!file.is_open()) { | ||
| logError("DBX Parser Error: Cannot open file: " + filename); | ||
| logError("DBX Parser Error: Cannot open file"); |
There was a problem hiding this comment.
|
The fix centralizes the file path in the 3dblox parser error report. Redundancies in dbxParser.cpp and dbvParser.cpp have been removed. |
Signed-off-by: Jorge Ferreira <jorge.ferreira@precisioninno.com>
|
clang-tidy review says "All clean, LGTM! 👍" |
src/odb/src/3dblox/baseParser.cpp
Outdated
| void BaseParser::logError(const std::string& message) | ||
| { | ||
| logger_->error(utl::ODB, 521, "Parser Error: {}", message); | ||
| if (!current_file_path_.empty()) { |
There was a problem hiding this comment.
would that ever happen?
That's right, sorry for the mistake, I've already corrected it.
src/odb/src/3dblox/dbvParser.cpp
Outdated
| std::ifstream file(filename); | ||
| if (!file.is_open()) { | ||
| logError("3DBV Parser Error: Cannot open file: " + filename); | ||
| logError("3DBV Parser Error: Cannot open file"); |
There was a problem hiding this comment.
| logError("3DBV Parser Error: Cannot open file"); | |
| logError("Cannot open file"); |
src/odb/src/3dblox/dbxParser.cpp
Outdated
| std::ifstream file(filename); | ||
| if (!file.is_open()) { | ||
| logError("DBX Parser Error: Cannot open file: " + filename); | ||
| logError("DBX Parser Error: Cannot open file"); |
There was a problem hiding this comment.
| logError("DBX Parser Error: Cannot open file"); | |
| logError("Cannot open file"); |
src/odb/src/3dblox/baseParser.cpp
Outdated
| logger_->error( | ||
| utl::ODB, 521, "Parser Error in {}: {}", current_file_path_, message); | ||
| } else { | ||
| logger_->error(utl::ODB, 521, "Parser Error: {}", message); | ||
| } |
There was a problem hiding this comment.
Should not use the same error code for 2 separate errors.
Remove unreachable else branch in BaseParser::logError and simplify error messages in DbvParser and DbxParser by removing redundant prefixes already included by logError. Signed-off-by: Jorge Ferreira <jorge.ferreira@precisioninno.com>
|
clang-tidy review says "All clean, LGTM! 👍" |
fix #10076