mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-22 22:32:28 +00:00
Report errors in string escape sequences more verbosely
This commit is contained in:
@@ -218,7 +218,7 @@ IfcCharacterDecoder::operator std::string() {
|
|||||||
(current_char == '\'' && parse_state == APOSTROPHE)
|
(current_char == '\'' && parse_state == APOSTROPHE)
|
||||||
) ) {
|
) ) {
|
||||||
if ( parse_state == APOSTROPHE && current_char != '\'' ) break;
|
if ( parse_state == APOSTROPHE && current_char != '\'' ) break;
|
||||||
throw IfcException("Invalid character encountered");
|
throw IfcInvalidTokenException(file->Tell(), current_char);
|
||||||
} else {
|
} else {
|
||||||
parse_state = hex = hex_count = 0;
|
parse_state = hex = hex_count = 0;
|
||||||
// NOTE: this is in fact wrong, this ought to be the representation of the character.
|
// NOTE: this is in fact wrong, this ought to be the representation of the character.
|
||||||
@@ -286,7 +286,7 @@ void IfcCharacterDecoder::dryRun() {
|
|||||||
(current_char == '\'' && parse_state == APOSTROPHE)
|
(current_char == '\'' && parse_state == APOSTROPHE)
|
||||||
) ) {
|
) ) {
|
||||||
if ( parse_state == APOSTROPHE && current_char != '\'' ) break;
|
if ( parse_state == APOSTROPHE && current_char != '\'' ) break;
|
||||||
throw IfcException("Invalid character encountered");
|
throw IfcInvalidTokenException(file->Tell(), current_char);
|
||||||
} else {
|
} else {
|
||||||
parse_state = hex_count = 0;
|
parse_state = hex_count = 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -67,8 +67,18 @@ namespace IfcParse {
|
|||||||
" invalid " + expected_type
|
" invalid " + expected_type
|
||||||
)
|
)
|
||||||
{}
|
{}
|
||||||
|
IfcInvalidTokenException(
|
||||||
|
int token_start,
|
||||||
|
char c
|
||||||
|
)
|
||||||
|
: IfcException(
|
||||||
|
std::string("Unexpected '") + std::string(1, c) + "' at " +
|
||||||
|
boost::lexical_cast<std::string>(token_start)
|
||||||
|
)
|
||||||
|
{}
|
||||||
~IfcInvalidTokenException() throw () {}
|
~IfcInvalidTokenException() throw () {}
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
|
|||||||
@@ -1098,8 +1098,15 @@ bool IfcFile::Init(IfcParse::IfcSpfStream* s) {
|
|||||||
MaxId = (std::max)(MaxId,currentId);
|
MaxId = (std::max)(MaxId,currentId);
|
||||||
currentId = 0;
|
currentId = 0;
|
||||||
} else {
|
} else {
|
||||||
try { token = tokens->Next(); }
|
try {
|
||||||
catch (... ) { token = NoneTokenPtr(); }
|
token = tokens->Next();
|
||||||
|
} catch (const IfcException& e) {
|
||||||
|
Logger::Message(Logger::LOG_ERROR, std::string(e.what()) + ". Parsing terminated");
|
||||||
|
token = NoneTokenPtr();
|
||||||
|
} catch (...) {
|
||||||
|
Logger::Message(Logger::LOG_ERROR, "Parsing terminated");
|
||||||
|
token = NoneTokenPtr();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ! (token.startPos || token.lexer) ) break;
|
if ( ! (token.startPos || token.lexer) ) break;
|
||||||
|
|||||||
Reference in New Issue
Block a user