mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-13 19:07:57 +00:00
Catch string encoding errors and set status #5992
This commit is contained in:
@@ -1309,7 +1309,13 @@ void IfcFile::initialize_(IfcParse::IfcSpfStream* s) {
|
||||
|
||||
parse_context ps;
|
||||
tokens->Next();
|
||||
load(current_id, entity_type->as_entity(), ps, -1);
|
||||
try {
|
||||
load(current_id, entity_type->as_entity(), ps, -1);
|
||||
} catch (const IfcInvalidTokenException& e) {
|
||||
good_ = file_open_status::INVALID_SYNTAX;
|
||||
Logger::Error(e);
|
||||
break;
|
||||
}
|
||||
instance = schema_->instantiate(entity_type, ps.construct(current_id, references_to_resolve, entity_type, boost::none));
|
||||
instance->file_ = this;
|
||||
instance->id_ = current_id;
|
||||
@@ -1391,6 +1397,11 @@ void IfcFile::initialize_(IfcParse::IfcSpfStream* s) {
|
||||
|
||||
delete tokens;
|
||||
|
||||
if (good_ != file_open_status::SUCCESS) {
|
||||
references_to_resolve.clear();
|
||||
return;
|
||||
}
|
||||
|
||||
for (const auto& p : references_to_resolve) {
|
||||
const auto& ref = p.first.name_;
|
||||
const auto& refattr = p.first.index_;
|
||||
|
||||
Reference in New Issue
Block a user