Suppress reports on some common exception throws
This commit is contained in:
@@ -552,10 +552,7 @@ bool SGBinObject::read_bin( const SGPath& file ) {
|
|||||||
withGZ.concat(".gz");
|
withGZ.concat(".gz");
|
||||||
fp = gzFileFromSGPath(withGZ, "rb");
|
fp = gzFileFromSGPath(withGZ, "rb");
|
||||||
if (fp == nullptr) {
|
if (fp == nullptr) {
|
||||||
SG_LOG( SG_EVENT, SG_ALERT,
|
throw sg_io_exception("Error opening for reading (and .gz)", sg_location(file), {}, false);
|
||||||
"ERROR: opening " << file << " or " << withGZ << " for reading!");
|
|
||||||
|
|
||||||
throw sg_io_exception("Error opening for reading (and .gz)", sg_location(file));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -569,7 +566,8 @@ bool SGBinObject::read_bin( const SGPath& file ) {
|
|||||||
int code = 0;
|
int code = 0;
|
||||||
const char* gzErrorString = gzerror(fp, &code);
|
const char* gzErrorString = gzerror(fp, &code);
|
||||||
gzclose(fp);
|
gzclose(fp);
|
||||||
throw sg_io_exception("Unable to read BTG header: " + string{gzErrorString} + ", code =" + std::to_string(code), sg_location(file));
|
throw sg_io_exception("Unable to read BTG header: " + string{gzErrorString} + ", code =" + std::to_string(code),
|
||||||
|
sg_location(file), {}, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ((header & 0xFF000000) >> 24) == 'S' &&
|
if ( ((header & 0xFF000000) >> 24) == 'S' &&
|
||||||
@@ -580,7 +578,7 @@ bool SGBinObject::read_bin( const SGPath& file ) {
|
|||||||
} else {
|
} else {
|
||||||
// close the file before we return
|
// close the file before we return
|
||||||
gzclose(fp);
|
gzclose(fp);
|
||||||
throw sg_io_exception("Bad BTG magic/version", sg_location(file));
|
throw sg_io_exception("Bad BTG magic/version", sg_location(file), {}, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
// read creation time
|
// read creation time
|
||||||
@@ -617,7 +615,10 @@ bool SGBinObject::read_bin( const SGPath& file ) {
|
|||||||
SG_LOG(SG_IO, SG_DEBUG, "SGBinObject::read_bin Total objects to read = " << nobjects);
|
SG_LOG(SG_IO, SG_DEBUG, "SGBinObject::read_bin Total objects to read = " << nobjects);
|
||||||
|
|
||||||
if ( sgReadError() ) {
|
if ( sgReadError() ) {
|
||||||
throw sg_io_exception("Error reading BTG file header", sg_location(file));
|
int code = 0;
|
||||||
|
const char* gzErrorString = gzerror(fp, &code);
|
||||||
|
throw sg_io_exception("Error reading BTG file header:" + string{gzErrorString} + ", code =" + std::to_string(code),
|
||||||
|
sg_location(file), {}, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
// read in objects
|
// read in objects
|
||||||
@@ -805,7 +806,10 @@ bool SGBinObject::read_bin( const SGPath& file ) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ( sgReadError() ) {
|
if ( sgReadError() ) {
|
||||||
throw sg_io_exception("Error while reading object", sg_location(file, i));
|
int code = 0;
|
||||||
|
const char* gzErrorString = gzerror(fp, &code);
|
||||||
|
throw sg_io_exception("Error reading BTG object:" + string{gzErrorString} + ", code =" + std::to_string(code),
|
||||||
|
sg_location(file, i), {}, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -75,13 +75,13 @@ BuilderException::BuilderException()
|
|||||||
}
|
}
|
||||||
|
|
||||||
BuilderException::BuilderException(const char* message, const char* origin)
|
BuilderException::BuilderException(const char* message, const char* origin)
|
||||||
: sg_exception(message, origin)
|
: sg_exception(message, origin, {}, false)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
BuilderException::BuilderException(const std::string& message,
|
BuilderException::BuilderException(const std::string& message,
|
||||||
const std::string& origin)
|
const std::string& origin)
|
||||||
: sg_exception(message, origin)
|
: sg_exception(message, origin, {}, false)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+35
-31
@@ -244,40 +244,43 @@ readXML (istream &input, XMLVisitor &visitor, const string &path)
|
|||||||
|
|
||||||
// FIXME: get proper error string from system
|
// FIXME: get proper error string from system
|
||||||
if (!input.good()) {
|
if (!input.good()) {
|
||||||
sg_io_exception ex ("Problem reading file",
|
sg_io_exception ex("Problem reading file",
|
||||||
sg_location(path,
|
sg_location(path,
|
||||||
XML_GetCurrentLineNumber(parser),
|
XML_GetCurrentLineNumber(parser),
|
||||||
XML_GetCurrentColumnNumber(parser)),
|
XML_GetCurrentColumnNumber(parser)),
|
||||||
"SimGear XML Parser");
|
"SimGear XML Parser",
|
||||||
visitor.setParser(0);
|
false /* don't report */);
|
||||||
XML_ParserFree(parser);
|
visitor.setParser(0);
|
||||||
throw ex;
|
XML_ParserFree(parser);
|
||||||
|
throw ex;
|
||||||
}
|
}
|
||||||
|
|
||||||
input.read(buf,16384);
|
input.read(buf,16384);
|
||||||
if (!XML_Parse(parser, buf, input.gcount(), false)) {
|
if (!XML_Parse(parser, buf, input.gcount(), false)) {
|
||||||
sg_io_exception ex (XML_ErrorString(XML_GetErrorCode(parser)),
|
sg_io_exception ex(XML_ErrorString(XML_GetErrorCode(parser)),
|
||||||
sg_location(path,
|
sg_location(path,
|
||||||
XML_GetCurrentLineNumber(parser),
|
XML_GetCurrentLineNumber(parser),
|
||||||
XML_GetCurrentColumnNumber(parser)),
|
XML_GetCurrentColumnNumber(parser)),
|
||||||
"SimGear XML Parser");
|
"SimGear XML Parser",
|
||||||
visitor.setParser(0);
|
false /* don't report */);
|
||||||
XML_ParserFree(parser);
|
visitor.setParser(0);
|
||||||
throw ex;
|
XML_ParserFree(parser);
|
||||||
|
throw ex;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Verify end of document.
|
// Verify end of document.
|
||||||
if (!XML_Parse(parser, buf, 0, true)) {
|
if (!XML_Parse(parser, buf, 0, true)) {
|
||||||
sg_io_exception ex (XML_ErrorString(XML_GetErrorCode(parser)),
|
sg_io_exception ex(XML_ErrorString(XML_GetErrorCode(parser)),
|
||||||
sg_location(path,
|
sg_location(path,
|
||||||
XML_GetCurrentLineNumber(parser),
|
XML_GetCurrentLineNumber(parser),
|
||||||
XML_GetCurrentColumnNumber(parser)),
|
XML_GetCurrentColumnNumber(parser)),
|
||||||
"SimGear XML Parser");
|
"SimGear XML Parser",
|
||||||
visitor.setParser(0);
|
false /* don't report */);
|
||||||
XML_ParserFree(parser);
|
visitor.setParser(0);
|
||||||
throw ex;
|
XML_ParserFree(parser);
|
||||||
|
throw ex;
|
||||||
}
|
}
|
||||||
|
|
||||||
visitor.setParser(0);
|
visitor.setParser(0);
|
||||||
@@ -300,8 +303,8 @@ readXML (const SGPath &path, XMLVisitor &visitor)
|
|||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
throw sg_io_exception("Failed to open file", sg_location(path),
|
throw sg_io_exception("Failed to open file", sg_location(path),
|
||||||
"SimGear XML Parser");
|
"SimGear XML Parser", false /* don't report */);
|
||||||
}
|
}
|
||||||
input.close();
|
input.close();
|
||||||
}
|
}
|
||||||
@@ -318,11 +321,12 @@ readXML (const char *buf, const int size, XMLVisitor &visitor)
|
|||||||
visitor.startXML();
|
visitor.startXML();
|
||||||
|
|
||||||
if (!XML_Parse(parser, buf, size, false)) {
|
if (!XML_Parse(parser, buf, size, false)) {
|
||||||
sg_io_exception ex (XML_ErrorString(XML_GetErrorCode(parser)),
|
sg_io_exception ex(XML_ErrorString(XML_GetErrorCode(parser)),
|
||||||
sg_location("In-memory XML buffer",
|
sg_location("In-memory XML buffer",
|
||||||
XML_GetCurrentLineNumber(parser),
|
XML_GetCurrentLineNumber(parser),
|
||||||
XML_GetCurrentColumnNumber(parser)),
|
XML_GetCurrentColumnNumber(parser)),
|
||||||
"SimGear XML Parser");
|
"SimGear XML Parser",
|
||||||
|
false /* don't report */);
|
||||||
XML_ParserFree(parser);
|
XML_ParserFree(parser);
|
||||||
throw ex;
|
throw ex;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user