Revamp exception handling. ImportErrorException renamed to DeadlyImportError to avoid silent regressions. Exceptions now thrown by value, and caught by reference. Put guards in all C++ and C API functions to avoid unwanted exception propagation across module and language boundaries.

PLEASE TEST CAREFULLY IF THIS SHOULD CAUSE REGRESSIONS.

git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@617 67173fc5-114c-0410-ac8e-9d2fd5bffc1f
This commit is contained in:
aramis_acg
2010-03-18 17:00:12 +00:00
parent 79c14ce896
commit 762a7df46a
61 changed files with 565 additions and 354 deletions

View File

@@ -117,7 +117,7 @@ void UnrealImporter::InternReadFile( const std::string& pFile,
// jjjj_a.3d
pos = pFile.find_last_of('_');
if (std::string::npos == pos) {
throw new ImportErrorException("UNREAL: Unexpected naming scheme");
throw DeadlyImportError("UNREAL: Unexpected naming scheme");
}
extension = pFile.substr(0,pos);
}
@@ -137,14 +137,14 @@ void UnrealImporter::InternReadFile( const std::string& pFile,
// and open the files ... we can't live without them
IOStream* p = pIOHandler->Open(d_path);
if (!p)
throw new ImportErrorException("UNREAL: Unable to open _d file");
throw DeadlyImportError("UNREAL: Unable to open _d file");
StreamReaderLE d_reader(pIOHandler->Open(d_path));
const uint16_t numTris = d_reader.GetI2();
const uint16_t numVert = d_reader.GetI2();
d_reader.IncPtr(44);
if (!numTris || numVert < 3)
throw new ImportErrorException("UNREAL: Invalid number of vertices/triangles");
throw DeadlyImportError("UNREAL: Invalid number of vertices/triangles");
// maximum texture index
unsigned int maxTexIdx = 0;
@@ -185,17 +185,17 @@ void UnrealImporter::InternReadFile( const std::string& pFile,
p = pIOHandler->Open(a_path);
if (!p)
throw new ImportErrorException("UNREAL: Unable to open _a file");
throw DeadlyImportError("UNREAL: Unable to open _a file");
StreamReaderLE a_reader(pIOHandler->Open(a_path));
// read number of frames
const uint32_t numFrames = a_reader.GetI2();
if (configFrameID >= numFrames)
throw new ImportErrorException("UNREAL: The requested frame does not exist");
throw DeadlyImportError("UNREAL: The requested frame does not exist");
uint32_t st = a_reader.GetI2();
if (st != numVert*4)
throw new ImportErrorException("UNREAL: Unexpected aniv file length");
throw DeadlyImportError("UNREAL: Unexpected aniv file length");
// skip to our frame
a_reader.IncPtr(configFrameID *numVert*4);
@@ -328,8 +328,9 @@ void UnrealImporter::InternReadFile( const std::string& pFile,
}
}
if (!pScene->mNumMeshes)
throw new ImportErrorException("UNREAL: Unable to find valid mesh data");
if (!pScene->mNumMeshes) {
throw DeadlyImportError("UNREAL: Unable to find valid mesh data");
}
// allocate meshes and bind them to the node graph
pScene->mMeshes = new aiMesh*[pScene->mNumMeshes];