Don't print check in case of throwing ov::Exception (#17699)

* Don't print check in case of throwing ov::Exception

* Fixed code style
This commit is contained in:
Ilya Churaev 2023-05-25 07:04:38 +04:00 committed by GitHub
parent a21fe95ae6
commit 9f1757f400
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -12,7 +12,11 @@ void ov::Exception::create(const CheckLocInfo& check_loc_info,
const std::string& context_info,
const std::string& explanation) {
OPENVINO_SUPPRESS_DEPRECATED_START
throw ov::Exception(make_what(check_loc_info, context_info, explanation));
CheckLocInfo loc_info;
loc_info.file = check_loc_info.file;
loc_info.line = check_loc_info.line;
loc_info.check_string = nullptr;
throw ov::Exception(make_what(loc_info, context_info, explanation));
OPENVINO_SUPPRESS_DEPRECATED_END
}
@ -30,8 +34,12 @@ std::string ov::Exception::make_what(const CheckLocInfo& check_loc_info,
return path.substr(project_root.length() + 1);
};
std::stringstream ss;
ss << "Check '" << check_loc_info.check_string << "' failed at " << getRelativePath(check_loc_info.file) << ":"
<< check_loc_info.line;
if (check_loc_info.check_string) {
ss << "Check '" << check_loc_info.check_string << "' failed at " << getRelativePath(check_loc_info.file) << ":"
<< check_loc_info.line;
} else {
ss << "Exception from " << getRelativePath(check_loc_info.file) << ":" << check_loc_info.line;
}
if (!context_info.empty()) {
ss << ":" << std::endl << context_info;
}