Vassilii Khachaturov:

* in some cases more specific sg exception types were used in place
  of the more generic one, e.g., sg_io_exception instead of sg_exception
  when the context of the error was an IO error
* in some cases, the error message was made more specific
* minor style fix for exception rethrowing --- using throw; whenever
  a re-throw is made; sometimes optimizing away the exception symbol name
  in the catch handler at all
* more specific catch handlers added in some places -- e.g.,
  an sg_io_exception caught ahead of sg_exception
This commit is contained in:
ehofman
2005-12-11 13:35:05 +00:00
parent 61da54d6ca
commit 8357eeb762
5 changed files with 18 additions and 13 deletions

View File

@@ -107,7 +107,7 @@ SGMetar::SGMetar(const string& m, const string& proxy, const string& port,
scanType();
if (!scanId() || !scanDate()) {
delete[] _data;
throw sg_io_exception("metar data bogus (" + _url + ')');
throw sg_io_exception("metar data bogus ", sg_location(_url));
}
scanModifier();
@@ -133,7 +133,7 @@ SGMetar::SGMetar(const string& m, const string& proxy, const string& port,
if (_grpcount < 4) {
delete[] _data;
throw sg_io_exception("metar data incomplete (" + _url + ')');
throw sg_io_exception("metar data incomplete ", sg_location(_url));
}
_url = "";
@@ -196,7 +196,7 @@ char *SGMetar::loadData(const char *id, const string& proxy, const string& port,
sock->set_timeout(10000);
if (!sock->open(SG_IO_OUT)) {
delete sock;
throw sg_io_exception("cannot connect to " + host);
throw sg_io_exception("cannot connect to ", sg_location(host));
}
string get = "GET ";
@@ -233,7 +233,8 @@ char *SGMetar::loadData(const char *id, const string& proxy, const string& port,
char *b = buf;
scanBoundary(&b);
if (*b == '<')
throw sg_io_exception("no metar data available from " + _url);
throw sg_io_exception("no metar data available from ",
sg_location(_url));
char *metar = new char[strlen(b) + 2]; // make room for " \0"
strcpy(metar, b);

View File

@@ -185,7 +185,7 @@ bool SGMaterialLib::load( const string &fg_root, const string& mpath, const char
} catch (const sg_exception &ex) {
SG_LOG( SG_INPUT, SG_ALERT, "Error reading materials: "
<< ex.getMessage() );
throw ex;
throw;
}
int nMaterials = materials.nChildren();

View File

@@ -283,7 +283,8 @@ sgLoad3DModel( const string &fg_root, const string &path,
ssgTexturePath((char *)texturepath.c_str());
model = (ssgBranch *)ssgLoad((char *)modelpath.c_str());
if (model == 0)
throw sg_exception("Failed to load 3D model");
throw sg_io_exception("Failed to load 3D model",
sg_location(modelpath.str()));
}
// Set up the alignment node
ssgTransform * alignmainmodel = new ssgTransform;

View File

@@ -118,7 +118,8 @@ SGSoundSample::SGSoundSample( const char *path, const char *file) :
if (buffer == AL_NONE) {
ALenum error = alutGetError ();
print_openal_error("constructor (alutCreateBufferFromFile)");
throw sg_exception("Failed to load wav file: "+string(alutGetErrorString (error)));
throw sg_io_exception("Failed to load wav file: ",
sg_location(string(alutGetErrorString (error))));
}
#else
@@ -383,7 +384,8 @@ SGSoundSample::load_file(const char *path, const char *file)
ALfloat freqf;
data = alutLoadMemoryFromFile(samplepath.c_str(), &format, &size, &freqf );
if (data == NULL) {
throw sg_exception("Failed to load wav file.");
throw sg_io_exception("Failed to load wav file.",
sg_location(samplepath.str()));
}
freq = (ALsizei)freqf;
#else
@@ -395,7 +397,8 @@ SGSoundSample::load_file(const char *path, const char *file)
&format, &data, &size, &freq, &loop );
# endif
if ( print_openal_error("constructor (alutLoadWAVFile)") ) {
throw sg_exception("Failed to load wav file.");
throw sg_io_exception("Failed to load wav file.",
sg_location(samplepath.str()));
}
#endif

View File

@@ -263,12 +263,12 @@ readXML (const string &path, XMLVisitor &visitor)
if (input.good()) {
try {
readXML(input, visitor, path);
} catch (sg_io_exception &e) {
} catch (sg_io_exception &) {
input.close();
throw e;
} catch (sg_throwable &t) {
throw;
} catch (sg_throwable &) {
input.close();
throw t;
throw;
}
} else {
throw sg_io_exception("Failed to open file", sg_location(path),