mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-13 10:57:49 +00:00
Fix #178
This commit is contained in:
@@ -37,6 +37,7 @@ void Logger::SetOutput(std::ostream* l1, std::ostream* l2) {
|
||||
log2 = &log_stream;
|
||||
}
|
||||
}
|
||||
|
||||
void Logger::Message(Logger::Severity type, const std::string& message, IfcEntityInstanceData* entity) {
|
||||
if ( log2 && type >= verbosity ) {
|
||||
(*log2) << "[" << severity_strings[type] << "] ";
|
||||
@@ -47,6 +48,11 @@ void Logger::Message(Logger::Severity type, const std::string& message, IfcEntit
|
||||
if ( entity ) (*log2) << entity->toString() << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
void Logger::Message(Logger::Severity type, const std::exception& exception, IfcEntityInstanceData* entity) {
|
||||
Message(type, exception.what(), entity);
|
||||
}
|
||||
|
||||
void Logger::Status(const std::string& message, bool new_line) {
|
||||
if ( log1 ) {
|
||||
(*log1) << message;
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
#include <vector>
|
||||
#include <sstream>
|
||||
#include <algorithm>
|
||||
#include <exception>
|
||||
|
||||
#ifdef USE_IFC4
|
||||
#include "../ifcparse/Ifc4.h"
|
||||
@@ -53,12 +54,21 @@ public:
|
||||
/// Determines the types of log messages to get logged
|
||||
static void Verbosity(Severity v);
|
||||
static Severity Verbosity();
|
||||
|
||||
/// Log a message to the output stream
|
||||
static void Message(Severity type, const std::string& message, IfcEntityInstanceData* entity=0);
|
||||
static void Notice(const std::string& message, IfcEntityInstanceData* entity = 0) { Message(LOG_NOTICE, message, entity); }
|
||||
static void Message(Severity type, const std::exception& message, IfcEntityInstanceData* entity = 0);
|
||||
|
||||
static void Notice(const std::string& message, IfcEntityInstanceData* entity = 0) { Message(LOG_NOTICE, message, entity); }
|
||||
static void Warning(const std::string& message, IfcEntityInstanceData* entity=0) { Message(LOG_WARNING, message, entity); }
|
||||
static void Error(const std::string& message, IfcEntityInstanceData* entity=0) { Message(LOG_ERROR, message, entity); }
|
||||
|
||||
static void Notice(const std::exception& exception, IfcEntityInstanceData* entity = 0) { Message(LOG_NOTICE, exception, entity); }
|
||||
static void Warning(const std::exception& exception, IfcEntityInstanceData* entity = 0) { Message(LOG_WARNING, exception, entity); }
|
||||
static void Error(const std::exception& exception, IfcEntityInstanceData* entity = 0) { Message(LOG_ERROR, exception, entity); }
|
||||
|
||||
static void Status(const std::string& message, bool new_line=true);
|
||||
|
||||
static void ProgressBar(int progress);
|
||||
static std::string GetLog();
|
||||
};
|
||||
|
||||
@@ -1254,7 +1254,10 @@ bool IfcFile::Init(IfcParse::IfcSpfStream* s) {
|
||||
std::vector<std::string> schemas;
|
||||
try {
|
||||
schemas = _header.file_schema().schema_identifiers();
|
||||
} catch (...) {}
|
||||
} catch (...) {
|
||||
// Purposely empty catch block
|
||||
}
|
||||
|
||||
if (schemas.size() != 1 || schemas[0] != IfcSchema::Identifier) {
|
||||
Logger::Message(Logger::LOG_ERROR, std::string("File schema encountered different from expected '") + IfcSchema::Identifier + "'");
|
||||
}
|
||||
@@ -1558,7 +1561,10 @@ IfcUtil::IfcBaseClass* IfcFile::addEntity(IfcUtil::IfcBaseClass* entity) {
|
||||
IfcEntityList::ptr entity_attributes(new IfcEntityList);
|
||||
try {
|
||||
entity_attributes = traverse(entity, 1);
|
||||
} catch (...) {}
|
||||
} catch (const std::exception& e) {
|
||||
Logger::Error(e);
|
||||
}
|
||||
|
||||
for (IfcEntityList::it it = entity_attributes->begin(); it != entity_attributes->end(); ++it) {
|
||||
IfcUtil::IfcBaseClass* entity_attribute = *it;
|
||||
if (*it == entity) continue;
|
||||
@@ -1567,7 +1573,9 @@ IfcUtil::IfcBaseClass* IfcFile::addEntity(IfcUtil::IfcBaseClass* entity) {
|
||||
unsigned entity_attribute_id = entity_attribute->entity->id();
|
||||
byref[entity_attribute_id].push_back(entity->entity->id());
|
||||
}
|
||||
} catch (const IfcParse::IfcException&) {}
|
||||
} catch (const std::exception& e) {
|
||||
Logger::Error(e);
|
||||
}
|
||||
}
|
||||
|
||||
return entity;
|
||||
|
||||
@@ -104,9 +104,10 @@ bool IfcSpfHeader::tryRead() {
|
||||
try {
|
||||
read();
|
||||
return true;
|
||||
} catch(const IfcException&) {
|
||||
} catch (const std::exception& e) {
|
||||
Logger::Error(e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void IfcSpfHeader::write(std::ostream& os) const {
|
||||
|
||||
Reference in New Issue
Block a user